skip to Main Content

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.

This is what my Editor sidebar looks like, in case that's what the issue is.

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


  1. Chosen as BEST ANSWER

    I had to change the directory to the one my app was actually in...duh


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search