This repository contains Flask instructional lessons, exercises, and exercise solutions. Lessons and exercises are based off of Rithm's "Flask and SQL Fundamentals" and "Intermediate Flask" courses, shared under this CC license. The lesson material has been archived here without modification aside from minor error corrections.
To use this repository, you can look at the lessons on Rithm's website or use the lesson.md file in each lesson folder. I have included notes for each section in each lesson's readme file under "Brendon's Notes." My solutions to each exercise, which pass all tests, are in the solutions folder or in solution.md depending on the section, and Rithm's solutions can be found here. For the Flask sections of the exercises there are tests in the test.py module which you can refer to while developing to see what the exercise expects.
The solutions were created with Flask version 1.0.2, Python version 3.6.5, and PostgreSQL version 10.3 and will likely be forward compatible with future releases.
The following setup instructions are for MacOS. For other operating systems see the Flask documentation on Installation and online Postgres resources which provide setup information for other operating systems.
The setup process, which differs from the setup instructions in each lesson, will make it so you do not have to create a new virtual environment to start each lesson or continually install requirements. Instead, these instructions create one virtual environment for the entire course which already has all requirements installed.
git clone
this repositorypython3 -m venv venv
from the main course folder to create a new virtual environment in the main course folder. venv/bin/activate
to enter the virtual environment (deactivate
to exit)pip install -r requirements.txt
to install/update all requirements
. venv/bin/activate
from the main course folder if the virtual environment is not activated- Complete an exercise, referring to the lesson content, tests, and, if necessary, the solutions
python3 test.py
to run tests of your solution- If you create your solution in a new folder or file, you will need to adjust the import statements of the test to import your solution correctly)
- To see more details about the tests, use the command
python3 test.py -v
- To test the solutions, run the file solution_test.py inside the solutions folder; solution_test.py is identical to the main tests aside from adjusted import statements
- Refer to the solution to see alternative ways of solving the same problem and improve your coding skills
- Install Homebrew if Homebrew is not already installed
brew install postgres
to install Postgresbrew services start postgresql
to start Postgres (brew services stop postgresql
to stop Postgres)psql database_name
to connect to a database
- 01 Introduction To Flask
- 02 Routing with Flask
- 03 Templating with Jinja2
- 04 CRUD with Flask
- 05 SQL With Flask and Postgres
- 06 SQL Alchemy, Part I
- 07 SQL Alchemy, Part II
- 08 Testing With Flask
- 09 Server Side Validation with WTForms
- 01 Structuring Larger Flask Applications
- 02 Many to Many
- 03 Hashing and Sessions
- 04 Authentication with Flask Login
- 05 OAuth with Flask
- HTML to Markdown converter: https://domchristie.github.io/turndown/
- HTML tables to Markdown tables converter: https://stevecat.net/table-magic