【发布时间】:2019-09-10 03:13:52
【问题描述】:
我正在尝试创建一个在根登录页面上有一个 HTML 表单的基本 Web 应用程序,然后在提交后,使用所需的输入运行 postgresql 查询,并将用户重定向到具有生成的 matplotlib 图表的页面他们的意见。在我的主要功能中,我有以下内容:
@app.route('/', methods=['POST'])
def main():
return render_template("main.html")
假设我的主 html 文件由烧瓶应用程序呈现。我在下面还有另一条路线:
@app.route('/query', methods=['POST'])
def queryPage():
# code to execute query with information
# passed from the main.html template
# then generate chart via matplotlib via returned information
return render_template("query.html")
我对如何从 main.html 中的表单获取输入以将信息发送回应用程序以在 /query 端点呈现感到困惑。如果有人能详细说明这一点,我将不胜感激。前端不是我的强项。谢谢!
【问题讨论】:
标签: python python-3.x matplotlib flask