<html>
<head>
</head>
<body>
<form>
<select multiple="multiple"
<option value="Hello">Hello</option>
</select>
</form>
</body>
</html>
我正在使用 postgresql 数据库,其中我有一列和一行说“你好”的表
我想提取该数据并使用 FLASK 将其显示为 html 表单中的选择选项。
谁能帮帮我, 提前致谢
最佳答案
看来您需要阅读 Flask 的 Quickstart学习一些基础知识。
这是满足您需求的最小应用程序。
查看函数:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
items = get_your_data_from_db()
return render_template('index.html', items=items)
templates/index.html
<html>
<head>
</head>
<body>
<form>
<select multiple="multiple">
{% for item in items %}
<option value="{{ item.field_name }}">{{ item.field_name }}</option>
{% endfor %}
</select>
</form>
</body>
</html>
关于html - 使用 Python-Flask 使用来自 postgresql 数据库的数据填充 html 下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50593981/