pythonflask

Flask run not working when running it on powershell


Error: Could not locate a Flask application. Use the 'flask --app' option, 'FLASK_APP' environment variable, or a 'wsgi.py' or 'app.py' file in the current directory.

I am trying to run flask as I am just starting to learn about back end but I cant seem to solve this problem. Please help


Solution

  • First check the working directory, you should be in the same directory that your flask app is, you can use cd c:/path/to/app to change directory or hold shift and right click in that directory and choose open powershell here.

    Also it is better to rename your app to app.py, flask will run it by default, otherwise you should set FLASK_APP variable with $env:FLASK_APP = "app_name.py"