Loading video player…

Running the Flask Project

Avatar image for Aurelio Hernández López

Aurelio Hernández López on Sept. 18, 2025

It would be good to mention that the name of the Python file has been changed from main.py (in the last video) to app.py (in the current video). The command python -m flask run does not work with main.py but it does with app.py. Could you further explain?

Avatar image for Bartosz Zaczyński

Bartosz Zaczyński RP Team on Sept. 19, 2025

@Aurelio Hernández López That’s a fair point, Aurelio. Thanks for flagging it!

As to your question, you can find the answer in Flask’s command-line help:

An application to load must be given with the ‘–app’ option, ‘FLASK_APP’ environment variable, or with a ‘wsgi.py’ or ‘app.py’ file in the current directory.

By default, Flask’s development server looks for your application code in the app.py module when you don’t specify any of the other options. You can be more explicit if you want to indicate a different file, such as main.py, using one of these commands:

$ python -m flask --app main run
$ FLASK_APP=main python -m flask run

On Windows, setting environment variables might look a bit different, though.

Become a Member to join the conversation.