Learnr

Learn Flask

Build small, clear Python web apps and grow them one piece at a time.

Free to start. No credit card. Or browse all courses.

What's inside your Flask course

A sample path Learnr builds for Flask. Your real course adapts to your goal and level.

  1. Virtual environments and a one-file Flask app
  2. Routing, requests and responses
  3. Jinja templates and static files
  4. Forms, sessions and user login
  5. Databases, blueprints and the app factory
  6. Testing, configuration and deployment

Flask is a lightweight Python web framework, often called a microframework because the core stays small. You map URLs to Python functions with the @app.route decorator, render HTML with Jinja templates, and read form data from the request object. Everything else, from database access to login, comes from extensions like Flask-SQLAlchemy and Flask-Login, so you choose your own pieces. That makes Flask a clear way to understand how web apps really work. A first app fits in a single file, then grows into blueprints and an application factory. Learnr builds a personalized Flask course taught in short, interactive lessons.

How to learn Flask, step by step

  1. Set up a virtual environment and a first app. Create a venv, pip install Flask, and write a hello world in app.py. Run it with flask --app app run --debug so the reloader and debugger are on while you experiment with routes.
  2. Learn routing and the request cycle. Add routes with variable parts like /user/<name>, accept GET and POST, and read request.form and request.args. Use url_for instead of hardcoded paths, and return redirects and JSON so you see each response type.
  3. Render pages with Jinja templates. Move HTML into a templates folder, create a base layout, and extend it with blocks. Practice loops, conditionals and filters, and remember Jinja escapes variables by default, which protects you from many injection bugs.
  4. Add a database and user accounts. Use Flask-SQLAlchemy to define models and query them, then add Flask-Login for sessions. Hash passwords with the helpers in Werkzeug's security module rather than storing them as plain text.
  5. Restructure with blueprints and an app factory. When one file gets crowded, split features into blueprints and create the app inside a create_app function. This pattern makes configuration and testing simpler, and it matches how larger Flask projects are laid out.
  6. Test, deploy and practice daily. Write pytest tests using app.test_client(), then deploy with Gunicorn behind a reverse proxy, never the development server. Short daily Learnr lessons keep routing, templates and request handling fresh.

What you'll learn

  • Create routes with URL variables and HTTP methods
  • Render pages with Jinja templates, inheritance and filters
  • Handle forms, sessions and flash messages
  • Store data with SQLAlchemy and organize code with blueprints
  • Test views with the test client and deploy behind a WSGI server

How long does it take to learn Flask?

If you know Python, you can build a working Flask app in 1 to 2 weeks at a few hours a week. Adding authentication, a database, tests and a real deployment usually takes 1 to 2 months. Starting Python from zero adds a month or two.

What you need before you start

Basic Python, including functions, dictionaries and decorators at a reading level, plus simple HTML. Understanding what an HTTP request is will help from day one.

Common mistakes to avoid

  • Running the built-in development server in production. Use a WSGI server such as Gunicorn or Waitress, ideally behind a reverse proxy.
  • Hardcoding the SECRET_KEY in source control. Load secrets from environment variables so sessions stay secure and credentials never leak.
  • Keeping a growing app in a single file far too long. Introduce blueprints and an application factory once you have several features.

How Learnr builds your course

Type your topic

Tell Learnr you want to learn Flask, or get as specific as you like.

Get a personalized course

Learnr instantly builds a full Flask course tailored to your goal and skill level.

Learn and level up

Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.

Flask questions, answered

Should I learn Flask or Django first?

Flask is smaller, so you see how routing, templates and databases connect. Django includes an admin, ORM and auth out of the box. Either works; pick Flask if you want to understand the parts.

Can Flask build APIs?

Yes. A route can return a dictionary and Flask turns it into JSON. Many small services and machine learning model endpoints are built with Flask.

Is Flask still worth learning next to FastAPI?

Yes. Flask remains widely used for server-rendered sites and simple services, and the ideas transfer directly. FastAPI is a strong choice when an async, typed API is the main goal.

Explore more courses

More programming and tech courses

See all programming and tech courses

Ready to learn Flask?

Start your free, personalized Flask course in seconds. It will be typed in and ready when you get there.

Start learning Flask

Free to start. No credit card.