gpt4 book ai didi

python - Flask render_template() 返回 "NameError: name ' app' 未定义”

转载 作者:太空狗 更新时间:2023-10-29 17:35:25 25 4
gpt4 key购买 nike

我正在遵循 Flask 快速入门指南。 http://flask.pocoo.org/docs/quickstart/#static-files 我按照指南操作时遇到此错误。

/application
/__init__.py
/templates
/hello.html

@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
return render_template('hello.html', name=name)

>python _init_.py
Traceback (most recent call last):
File "_init_.py", line 4, in <module>
@app.route('/hello/')
NameError: name 'app' is not defined

最佳答案

也许是这个?

from flask import Flask, request, render_template

关于python - Flask render_template() 返回 "NameError: name ' app' 未定义”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10810206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com