This is a basic web application that has a home page and an about page. The home page is routed to localhost:5000/
and localhost:5000/home
. The about page is routed to localhost:5000/about
. This is a basic proof of concept project that shows how to set up a python Flask web application for learning purposes.
Tutorial Being Followed: Corey Schafer Flask Tutorial - https://youtube.com/playlist?list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH
- Python
- Pip
- Flask
- A text editor
- First check if python is installed or not by opening your terminal and typing the following command.
python --version
- If python is properly installed your output should look like:
Python 3.8.5
- If your version of python is earlier than this, you need to install the latest version of python.
- Install python: https://www.python.org/downloads/
- First check if pip is properly installed or not by opening your terminal and typing the following command:
pip --version
- If python is properly installed your output should look like:
pip 20.3.3
- If your version of pip is earlier than this, you need to install the latest version of pip.
- Install Pip: https://pip.pypa.io/en/stable/installing/
- First check if Flask is installed or not by opening your terminal and typing the following command.
flask --verison
- If Flask is properly installed your output should look like:
Python 3.8.5
Flask 1.1.2
Werkzeug 1.0.1
- If your version of flask is earlier than this, you need to install the latest version of flask.
- Install Flask by running the following command:
pip install flask
- Make sure Flask installed correctly by starting up python and importing flask
- Open your terminal
- start python by typing the following command:
python
- Python should now start and your terminal will have a
>>>
infront of your cursor - Type the following command and hit
enter
import flask
- If this runs with no errors then flask is installed properly. If errors occur, flask needs to be properly installed. * See https://flask.palletsprojects.com/en/1.1.x/installation/ for further installation documentation.
- Type the following command to exit the python editor in your terminal
exit()
- In our case, run the following command for linux/mac
export FLASK_APP=HelloWorld_Flask.py
- For windows run
set FLASK_APP=HelloWorld_Flask.py
flask run
* Serving Flask app "HelloWorld_Flask.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
- You can also replace the
127.0.0.1
withlocalhost
- eg. instead of navigating to http://127.0.0.1:5000/ you can navigate to http://localhost:5000/