I am following along with this tutorial on creating a simple flask app with VSC and cannot get app.py to run at all.
The author instructs
"In the Integrated Terminal, run the app by entering python -m flask run, which runs the Flask development server. The development server looks for app.py by default. When you run Flask, you should see output similar to the following:"
(.venv) D:py\hello_flask>python -m flask run
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
I instead am seeing this when i run the same command.
python -m flask run
Usage: python -m flask run [OPTIONS]
Try 'python -m flask run --help' for help.
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 could really use some help here. I feel so stupid for getting so something so simple so wrong and not being able to figure it out.
2
Answers
I had to change the directory to the one my app was actually in...duh
Obviously your
app.py
file was placed in the .vscode folder, which should be in the root directory of your workspace.Solution:
Move the
app.py
to the root directory of the workspace, which is the hello_flask folder.The .vscode folder is typically used to place workspace settings or configuration files such as launch.json.