Valeria
Valeria

Reputation: 1362

Flask NoAppException

I am trying to create a simple Flask app, but I get flask.cli.NoAppException if I try to start it with flask run. I simplified the code to literally few lines but I still get the same error:

dashboards.py:

from flask import Flask
server = Flask(__name__)

.flaskenv:

FLASK_APP=dashboards.py
FLASK_ENV=development

I have the file with Flask in the same directory where I run flask run:

enter image description here

(Moreover, I did one Flask app just few days ago and I did not have a problem like this.)

Is there anything I am missing?

Upvotes: 1

Views: 248

Answers (1)

Mikhail Burshteyn
Mikhail Burshteyn

Reputation: 5002

The FLASK_APP environment variable should be set to dashboards:server, where dashboards is the name of the Python module (not file) and server is the name of the application instance.

With your current setup, Flask tries to import module dashboard.py (i.e. searches for file dashboard/py.py) and find an application instance with a standard name app or application or an application factory with a standard name make_app or create_app.

See more docs on FLASK_APP here.

Upvotes: 1

Related Questions