Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python从postgresql数据库中获取的数据填充html下拉列表_Html_Forms_Postgresql_Flask_Drop Down Menu - Fatal编程技术网

使用Python从postgresql数据库中获取的数据填充html下拉列表

使用Python从postgresql数据库中获取的数据填充html下拉列表,html,forms,postgresql,flask,drop-down-menu,Html,Forms,Postgresql,Flask,Drop Down Menu,看来你需要读一下Flask的书来学习一些基础知识 这是一个满足您需求的最小应用程序 查看功能: 模板/index.html {items%%中的项的%s} {{item.field_name} {%endfor%} 这实际上与上述发布相反,我需要数据库(postgresql)中的数据以选择html形式发布,不是使用php,而是使用python flaskAh gotcha,标志已删除! <html> <head> </head> <body&g

看来你需要读一下Flask的书来学习一些基础知识

这是一个满足您需求的最小应用程序

查看功能:

模板/index.html


{items%%中的项的%s}
{{item.field_name}
{%endfor%}

这实际上与上述发布相反,我需要数据库(postgresql)中的数据以选择html形式发布,不是使用php,而是使用python flaskAh gotcha,标志已删除!
<html>
  <head>
  </head>
<body>
<form>
<select multiple="multiple" 
<option value="Hello">Hello</option>
</select>
</form>
</body>
</html>
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)
<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>