1 回答
TA贡献1909条经验 获得超7个赞
from flask import render_template
import flask
yourdb=[
("your data 1.1","your data 1.2"),
("your data 2.1","your data 2.2"),
("your data 3.1", "your data 3.2")
]
@app.route("/")
def main():
return render_template("index.html",data=yourdb)
和html页面
<html>
<head>
<title>
İndex
</title>
</head>
<body>
<table>
<tr>
<td>
Your column Name 1
</td>
<td>
Your Column Name 2
</td>
</tr>
{% for x in data %}
<tr>
<td>
{{x[0]}}
</td>
<td>
{{x[1]}}
</td>
</tr>
{% endfor %}
</table>
</body>
</html>
文件夹结构
--templates
| |__index.html
|
--flashapp.py
添加回答
举报