Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flask.cli.NoAppException: Failed to find Flask application or factory in module "flaskr". Use "FLASK_APP=flaskr:name to specify one

Tags:

python

flask

I am building a python web application using flask and following tutorial from http://flask.pocoo.org/docs/1.0/tutorial/factory/ . I am running the flask from the parent directory but getting following error.

(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 -

Please help.

I have tried Running Flask app from cli gives "no module named flaskr" and flask.cli.NoAppException: Failed to find application in module?

like image 967
Ashish Avatar asked Oct 31 '25 22:10

Ashish


1 Answers

I have found my problem. I was missing return app as the last statement in my code. Sorry for confusion and apologies.

like image 129
Ashish Avatar answered Nov 02 '25 10:11

Ashish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!