Check to see if you already have Python installed on your system by running:
On a Mac:
python3 --version
On Windows:
python --version
If you already have Python installed, check to be sure it’s Python 3.8 or up. (For example, 3.11 is great!) We suggest waiting on 3.12 to give any dependencies time to be updated.
If you are using a Windows machine, it is possible that you don’t have Python installed. You’ll need to pause here for a moment and proceed to install it. See this document for more information.
The script will be run in a virtual environment. Start by creating a virtual environment. Navigate to to the project folder in the command line and run:
On a Mac:
python3 -m venv venv
On Windows:
python -m venv venv
After creating the virtual environment, you need to activate it:
On a Mac:
source venv/bin/activate
On Windows:
source venv/Scripts/activate
Once the virtual environment is activated, the beginning of your terminal prompt should display (venv).
Install the modules by running (in both a Mac and Windows):
pip install flask
You'll see a venv folder has been added to the directory with all of the installed dependencies. If your project includes additional dependencies to be installed, you can add them after "flask", leaving a space between each dependency.
To run your code, in the command line run:
Without a debugger:
flask run
With a debugger:
flask run --debug
The app will run at: http://127.0.0.1:5000/
To stop the run, click control + C.
When making changes to your Python, HTML, or JavaScript code (and not using debugger) you'll need to stop the run after each change. After starting the run again, hard refresh the page.
When finished, quit the run by clicking control + C and close the virtual environment by running:
deactivate