app.py
from flask import Flask,render_template
app = Flask(__name__)
@app.route('/')
def index():
items = ['item1', 'item2', 'item3']
return render_template('index.html', items=items)
if __name__ == '__main__':
app.run(debug=True)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Flask 循环创建 HTML 标签示例</title>
</head>
<body>
<ul>
{% for item in items %}
<li>{{ item }}</li>
{% endfor %}
</ul>
</body>
</html>
标签:__,index,flask,标签,app,Flask,HTML,items From: https://www.cnblogs.com/full-stack-linux-new/p/17855925.html