我正在使用 Flask 和来自http://flask.pocoo.org/docs/1.0/tutorial/factory/ 的教程构建一个 python web 应用程序。我正在从父目录运行烧瓶,但出现以下错误。
(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 -
Run Code Online (Sandbox Code Playgroud)
请帮忙。
我试过从 cli 运行 Flask 应用程序给出“没有名为flaskr 的模块” 和 flask.cli.NoAppException: Failed to find application in module?
我发现了我的问题。我return app在我的代码中作为最后一个语句丢失了。抱歉给您带来困惑和歉意。
| 归档时间: |
|
| 查看次数: |
13008 次 |
| 最近记录: |