gpt4 book ai didi

python - flask.cli.NoAppException : Failed to find Flask application or factory in module "flaskr". 使用“FLASK_APP=flaskr:name 指定一个

转载 作者:行者123 更新时间:2023-11-30 21:57:36 25 4
gpt4 key购买 nike

我正在使用 Flask 构建一个 Python Web 应用程序,并遵循 http://flask.pocoo.org/docs/1.0/tutorial/factory/ 中的教程。我正在从父目录运行 flask ,但出现以下错误。

(venv) E:\python-code\python-web>flask run
* Serving Flask app "flaskr" (lazy loading)
* Environment: development
* Debug mode: on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 294-690-396
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [16/Mar/2019 13:10:43] "GET /hello HTTP/1.1" 500 -
Traceback (most recent call last):
File "e:\python-code\python-web\venv\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value
File "e:\python-code\python-web\venv\lib\site-packages\flask\cli.py", line 95, in find_best_app
module=module.__name__
flask.cli.NoAppException: Failed to find Flask application or factory in module "flaskr". Use "FLASK_APP=flaskr:name to specify one.
127.0.0.1 - - [16/Mar/2019 13:10:43] "GET /hello?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
127.0.0.1 - - [16/Mar/2019 13:10:43] "GET /hello?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -
127.0.0.1 - - [16/Mar/2019 13:10:43] "GET /hello?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
127.0.0.1 - - [16/Mar/2019 13:10:43] "GET /hello?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -
127.0.0.1 - - [16/Mar/2019 13:10:44] "GET /hello?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
127.0.0.1 - - [16/Mar/2019 13:10:44] "GET /hello?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -

请帮忙。

我已经尝试过Running Flask app from cli gives "no module named flaskr"flask.cli.NoAppException: Failed to find application in module?

最佳答案

我发现了我的问题。我缺少 return app 作为代码中的最后一条语句。抱歉造成困惑并致歉。

关于python - flask.cli.NoAppException : Failed to find Flask application or factory in module "flaskr". 使用“FLASK_APP=flaskr:name 指定一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55199434/

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