Flask app getting error of "could not locate flask application. .....FLASK_APP environment variable" for Flask Migrate
flask command line argument needs to know what module to locate the current
Flask app instance in.
FLASK_APP as an environment variable:
before running your
flask command-line app.
See the Command Line Interface documentation:
For the flask script to work, an application needs to be discovered. This is achieved by exporting the
FLASK_APPenvironment variable. It can be either set to an import path or to a filename of a Python module that contains a Flask application.
You can also set the variable per command by setting it on the same command line:
FLASK_APP=db_table.py flask db init
You can refer to this documentation to learn how to set environment variables in Flask.
Unix Bash (Linux, Mac, etc.):
$ export FLASK_APP=hello $ flask run
> set FLASK_APP=hello > flask run
> $env:FLASK_APP = "hello" > flask run