Flask
Curriculum
Flask · Python web

Flask Tutorial

A complete Flask path from beginner to pro - lightweight Python web apps with routes, Jinja, SQLAlchemy, auth, APIs, and deployment.

65 lessonsBeginner → ProBackend
Start from the beginning

Curriculum

Work through each section in order. Every lesson ends with practice and key points so the idea sticks.

Beginner

Getting Started

5 lessons · ~51 min
  1. 1
    What is Flask?

    Learn what Flask is, why it is called a microframework, and what kinds of Python web apps it can build.

  2. 2
    Flask vs Django (When to Choose)

    Compare Flask and Django so you can choose the right Python web framework for different beginner projects.

  3. 3
    Install Flask & Virtual Environments

    Set up a Flask 3.x project with a virtual environment, install Flask, and confirm the command line tools work.

  4. 4
    Your First Flask App

    Create a first Flask app with routes, simple responses, and the modern `flask --app` command.

  5. 5
    Dev Server, Debug Mode & Reloader

    Use the Flask development server safely, understand debug mode, and work with the automatic reloader.

Beginner

Routing

4 lessons · ~44 min
  1. 6
    Routes & View Functions

    Learn how Flask routes map URLs to view functions and how to organize simple page handlers.

  2. 7
    Dynamic Routes & Converters

    Use dynamic URL segments and converters to capture values from paths in Flask routes.

  3. 8
    GET, POST & Other Methods

    Understand HTTP methods and configure Flask routes that respond to GET, POST, and other request types.

  4. 9
    url_for & Endpoint Names

    Generate URLs with `url_for()` instead of hardcoding paths in Flask views and templates.

Beginner

Request & Response

3 lessons · ~34 min
  1. 10
    The request Object

    Read query strings, form data, headers, and JSON input from Flask requests.

  2. 11
    Responses, JSON & Status Codes

    Return strings, HTML, JSON, tuples, response objects, and meaningful status codes from Flask views.

  3. 12
    Redirects & abort()

    Send users to another URL with redirects and stop requests with `abort()` for standard error responses.

Beginner

Templates

4 lessons · ~47 min
  1. 13
    Jinja2 Templates Basics

    Render HTML templates with Flask and pass Python data into Jinja2 pages.

  2. 14
    Template Inheritance

    Create a shared base template with Jinja blocks so pages can reuse layout, navigation, and structure.

  3. 15
    Template Filters & Control Structures

    Use Jinja filters, if statements, loops, and empty states to make templates more expressive.

  4. 16
    Static Files (CSS/JS/Images)

    Serve CSS, JavaScript, and images from Flask's `static/` folder and link to them with `url_for()`.

Beginner

Forms & Feedback

3 lessons · ~38 min
  1. 17
    HTML Forms with Flask

    Build plain HTML forms, submit them to Flask routes, validate simple input, and redirect after POST.

  2. 18
    Flask-WTF & WTForms

    Use Flask-WTF and WTForms for structured form classes, validation, CSRF protection, and cleaner templates.

  3. 19
    Flash Messages

    Show one-time success, error, and info messages after redirects with Flask's flashing system.

Beginner

State

3 lessons · ~33 min
  1. 20
    Sessions

    Store small pieces of user-specific state with Flask sessions, such as display names or simple preferences.

  2. 21
    Cookies

    Read, set, and delete browser cookies in Flask while understanding how cookies differ from sessions.

  3. 22
    Custom Error Pages

    Create friendly custom pages for common Flask errors such as 404 Not Found and 500 Server Error.

Beginner

App Structure

3 lessons · ~39 min
  1. 23
    Configuration Basics

    Manage Flask configuration values for secrets, debug settings, feature flags, and environment-specific behavior.

  2. 24
    Application Factory Pattern

    Structure Flask apps with a `create_app()` function so configuration, tests, extensions, and blueprints are easier to manage.

  3. 25
    Blueprints Intro

    Organize related routes with Flask blueprints and register them in an application factory.

Intermediate

Database

6 lessons · ~85 min
  1. 26
    Flask-SQLAlchemy Setup

    Install Flask-SQLAlchemy, configure a database URL, and initialize the extension with the application factory pattern.

  2. 27
    Models & Tables

    Define SQLAlchemy models with columns, constraints, defaults, and helpful representation methods.

  3. 28
    Flask-Migrate & Alembic

    Use Flask-Migrate to create, review, and apply Alembic migrations as your database schema changes.

  4. 29
    CRUD with SQLAlchemy

    Build create, read, update, and delete routes using SQLAlchemy sessions and Flask redirects.

  5. 30
    Model Relationships

    Connect models with one-to-many and many-to-many relationships using foreign keys and relationship attributes.

  6. 31
    Querying Like a Pro

    Write focused SQLAlchemy queries with filters, ordering, joins, pagination, eager loading, and aggregate counts.

Intermediate

Auth

4 lessons · ~51 min
  1. 32
    Password Hashing

    Store passwords safely with Werkzeug hashing helpers and never keep raw passwords in the database.

  2. 33
    Flask-Login

    Add session-based user authentication with Flask-Login, user loaders, login_user, logout_user, and current_user.

  3. 34
    Signup, Login & Logout Flows

    Put practical authentication routes, templates, validation, flash messages, and redirects together.

  4. 35
    Protecting Routes & Roles

    Restrict pages to logged-in users and add role-based authorization decorators for admin-only behavior.

Intermediate

App Features

4 lessons · ~51 min
  1. 36
    File Uploads

    Accept uploaded files safely, validate filenames and extensions, store files, and serve uploaded assets.

  2. 37
    Sending Email

    Configure Flask-Mailman style SMTP settings, send transactional email, and keep email sending testable.

  3. 38
    Pagination

    Split long result sets into pages using Flask-SQLAlchemy paginate() and build page navigation links.

  4. 39
    Search & Filtering

    Build search and filter routes that compose SQLAlchemy conditions from query string parameters.

Intermediate

APIs

4 lessons · ~50 min
  1. 40
    REST API Basics with Flask

    Design resource-oriented Flask routes with HTTP methods, status codes, and JSON responses.

  2. 41
    Building JSON APIs

    Create consistent JSON serialization, request validation, and response envelopes for Flask APIs.

  3. 42
    API Error Handling

    Return useful JSON errors with custom error handlers, abort descriptions, validation errors, and database rollback.

  4. 43
    CORS for Frontend Apps

    Configure Cross-Origin Resource Sharing so browser frontends can call your Flask API safely.

Intermediate

Tooling

2 lessons · ~24 min
  1. 44
    Custom Flask CLI Commands

    Add flask commands for database seeding, user creation, maintenance tasks, and local automation.

  2. 45
    Logging

    Use Python logging in Flask apps to record errors, request context, and operational events.

Intermediate

Quality

3 lessons · ~38 min
  1. 46
    Testing Flask Apps

    Write pytest tests for Flask routes, app factories, database behavior, and authenticated clients.

  2. 47
    before_request & Context Processors

    Use Flask request hooks and context processors to prepare request data and share template helpers.

  3. 48
    Useful Flask Extensions

    Choose common Flask extensions for forms, auth, databases, APIs, admin panels, caching, and background jobs.

Advanced

Quality & Safety

2 lessons · ~35 min
  1. 49
    Flask Security Essentials

    Protect a Flask application with safe configuration, password hashing, session settings, authorization checks, and production habits.

  2. 50
    CSRF, XSS & Secure Headers

    Defend Flask forms and templates against CSRF, XSS, clickjacking, MIME sniffing, and common browser-side security mistakes.

Advanced

Pro Architecture

3 lessons · ~50 min
  1. 51
    Structuring Larger Flask Apps

    Organize a larger Flask codebase with an application factory, extensions module, feature packages, service functions, and clear boundaries.

  2. 52
    Blueprints at Scale

    Use Flask blueprints for large features, nested URL design, error handlers, template organization, and reusable registration patterns.

  3. 53
    Environments & Secrets

    Manage development, testing, staging, and production configuration without leaking secrets or hard-coding deployment values.

Advanced

Shipping

3 lessons · ~49 min
  1. 54
    Deploying Flask (Gunicorn & Beyond)

    Prepare Flask for deployment with a WSGI entrypoint, Gunicorn, environment variables, process management, logging, and health checks.

  2. 55
    PostgreSQL with Flask

    Connect Flask to PostgreSQL with SQLAlchemy, environment database URLs, migrations, connection pooling, and production-safe query habits.

  3. 56
    Static Assets in Production

    Serve CSS, JavaScript, images, and uploaded media efficiently with cache headers, hashed filenames, CDNs, and clean Flask template links.

Advanced

Performance

3 lessons · ~51 min
  1. 57
    Caching Strategies

    Improve Flask response time with safe caching layers, cache keys, Redis-style stores, invalidation habits, and template fragment caching.

  2. 58
    Background Tasks (Celery-style Intro)

    Understand when Flask work should move out of the request cycle and how Celery-style workers, queues, retries, and task status fit together.

  3. 59
    Performance Mindset

    Find Flask performance problems with measurement, query tuning, pagination, response size reduction, and request lifecycle awareness.

Advanced

Capstone Projects

3 lessons · ~60 min
  1. 60
    Mini Project: Blog App

    Build a small but production-shaped Flask blog with an app factory, blueprints, SQLAlchemy models, templates, forms, and publishing flow.

  2. 61
    Mini Project: JSON API

    Build a small Flask JSON API with versioned blueprints, request validation, SQLAlchemy persistence, JSON errors, and curl-based testing.

  3. 62
    Mini Project: SaaS Dashboard Shell

    Build a SaaS-style Flask dashboard shell with application layout, login-protected pages, organizations, settings, and extension points.

Advanced

Polish & Next Steps

3 lessons · ~42 min
  1. 63
    Common Flask Mistakes (and Fixes)

    Recognize frequent Flask problems around globals, debug mode, database sessions, templates, forms, blueprints, and production readiness.

  2. 64
    Flask Ecosystem & When to Use Flask

    Understand the Flask extension ecosystem and decide when Flask is a strong fit compared with larger frameworks or async-first tools.

  3. 65
    What to Learn After Flask

    Choose a practical learning path after Flask: testing, databases, security, deployment, APIs, frontend integration, and system design.