Flask
A small, explicit Python web framework.
Flask is taught here in 12 lessons, running from Your first Flask app through to Deployment: gunicorn, nginx and Docker. Each lesson takes one topic, shows the working code, and links onward to the next, so the course can be read straight through in order.
| Track | Python & Data Science |
| Lessons | 12 |
| Level | Beginner to intermediate |
| Reading time | about 3 hours |
| Prerequisites | Helpful, but not required: Jupyter Notebook |
Lessons
- Your first Flask appRoutes, view functions, the development server, and how Flask decides which function handles a request.
- Templates with Jinja2Passing data into templates, inheritance with blocks, escaping (and the one line that disables it).
- Forms, sessions and errorsReading request data, validating it, flashing messages, keeping a session, and returning sensible error responses.
- Routing in depth: converters, methods and url_forUse URL converters well, handle HTTP methods and trailing slashes deliberately, and build every link from an endpoint name instead of a hard-coded path.
- Blueprints and the application factorySplit a growing app into blueprints, build the app inside create_app() for testability, and initialise extensions without circular imports.
- Configuration and project structureOrganise config as classes, read secrets from the environment, keep machine-specific files in the instance folder, and make development and production differ only where they must.
- Databases with Flask-SQLAlchemyDefine models, query them through the session, handle transactions without leaving the session broken, and avoid the lazy-loading traps that make pages slow.
- Schema migrations with Flask-MigrateInitialise Alembic through Flask-Migrate, review the scripts autogenerate produces, and apply schema and data changes in a controlled order.
- Authentication with Flask-Login and password hashingGive users real passwords with Werkzeug hashing, keep them signed in with Flask-Login, protect routes, and gate features by role without breaking open redirects.
- Building and testing a JSON APIReturn consistent JSON with honest status codes, then test the contract with the test client, fixtures and a database that is not the one you develop on.
- File uploads, static files and sending emailAccept uploads without writing an attacker-controlled filename, cache static assets correctly, and send mail without blocking the request that triggered it.
- Deployment: gunicorn, nginx and DockerRun Flask under a real WSGI server, put nginx in front for TLS and static files, and containerise the app without baking secrets into the image.
More in Python & Data Science
Python 3 NumPy pandas Matplotlib Jupyter Notebook FastAPI Django SciPy Pillow Python 2.x R Julia
FAQ
How long does the Flask course take?
It has 12 lessons, about 3 hours of reading. Expect roughly twice that if you type out and run every example.
Do I need prior experience for Flask?
Not strictly. It helps to have read Jupyter Notebook first, because some lessons build on it, but every lesson explains its own assumptions.
What should I read after Flask?
Continue with FastAPI (3 lessons), the next course in Python & Data Science.
Last refreshed 2026-09-18.