Skip to content

vaylon-fernandes/flask_to_do_list

Repository files navigation

flask_to_do_list

A To Do list application created using flask-sqlalchemy and bootstrap

Demo

See a live version deployed on heroku here
Clone the project

  git clone https://github.com/vaylon-fernandes/flask_weather_app.git

Go to the project directory

  cd flask_to_do_list

Create a virtual enviroment. Read more

  venv <environment name>
Note: Linux users might have to install venv using the following command
   apt-get install python3-venv

Activate the virtual environment

On Linux:

source venv/bin/activate

On Windows:

venv\Scripts\activate

Install Reqirements

  pip install -r requirements.txt

Configuring environment Variables

  • Firstly Generate a Secret Key. This is required by the Flask Sessions. Do read the section on How to generate good secret keys in the flask documentation under sessions here
  • Next export the secret key to Enviroment Variables using one of the following commands based on your terminal Bash command
  export SECRET_KEY=<your secret key>

CMD command

  set SECRET_KEY=<your secret key>

Powershell command

  $env:SECRET_KEY=<your secret key>

The enviroment variables are then read using the os.environ object

Running the app

To run the app, first export the FLASK_APP variable, using one of the following commands based on your terminal
Bash command

  export FLASK_APP=main

CMD command

  set FLASK_APP=main

Powershell command

  $env:FLASK_APP = "hello"

Run command

flask run

This creates a simple server, go to http://127.0.0.1:5000/ in your browser to view the site

Debug mode

To run the server in Debug mode, export the FLAK_ENV variable befor running flask run Bash command

  export FLASK_ENV=development

CMD command

  set FLASK_ENV=development

Powershell command

  $env:FLASK_ENV="development"

Run command

flask run

Read more here: https://flask.palletsprojects.com/en/2.0.x/quickstart/#debug-mode

Deploying to Heroku

  • There's a good explanation of this given in this repo
  • Another good read on the topic is on the Real Python website

References

  1. Freecodecamp video - https://youtu.be/Z1RJmh_OqeA
  2. Tech With Tim youtube video - https://youtu.be/dam0GPOAvVI
  3. Flask Docs - https://flask.palletsprojects.com/en/2.0.x/
  4. Flask SQLAlchemy - https://flask-sqlalchemy.palletsprojects.com/en/2.x/
  5. Flask login docs - https://flask-login.readthedocs.io/en/latest/