Flask by Example

Learning PathSkills: Web Development, Flask Framework, Jinja, REST APIs, Databases, JavaScript Front Ends, Deployment

A big flask filled with a yellow liquid in a glass box, surrounded a computer, levers, and scientific flasks

Flask gives you a lightweight starting point for Python web development and lets you add exactly the pieces you need. This learning path guides you through building complete Flask applications step by step.

By completing this path, you’ll be able to:

  • Build scalable Flask web applications with databases
  • Create REST APIs using Flask, Connexion, and SQLAlchemy
  • Add logging and notification messages to your projects
  • Connect a JavaScript front end to a Flask API
  • Deploy your Flask applications to the web

This path is for Python developers who want to build web applications with a framework that stays out of your way. You should be comfortable with Python basics.

You’ll start with HTML, CSS, and Jinja templating, then build progressively larger Flask projects before tackling REST APIs, front-end integration, and deployment.

Flask by Example

Learning Path ⋅ 12 Resources

Laying the Foundation for Web Development

Before you jump into web development with Flask, it’s important to brush up on some foundational skills, like understanding HTML, CSS, and Jinja templating.

Title image for HTML and CSS Foundations for Python Developers (HTML and CSS for Python Developers)

Course

HTML and CSS Foundations for Python Developers

There's no way around HTML and CSS when you want to build web apps. Even if you're not aiming to become a web developer, knowing the basics of HTML and CSS will help you understand the Web better. In this video course, you'll get an introduction to HTML and CSS for Python programmers.

Title image for Jinja Templating (Jinja Templating Engine)

Course

Jinja Templating

With Jinja, you can build rich templates that power the front end of your web applications. But you can also use Jinja without a web framework running in the background. Whenever you need to generate text files with dynamic content, Jinja provides a flexible and powerful solution.

Title image for Primer on Jinja Templating (Jinja Templating Engine)

Interactive Quiz

Primer on Jinja Templating

Getting Started With Flask

Now that you’ve covered HTML, CSS, and Jinja templating, you’re ready to build your first Flask project. You’ll structure a scalable application from scratch, add logging and notification messages, then connect it to a database. Those are the pieces that turn a single-file demo into an application you can keep building on.

Title image for Creating a Scalable Flask Web Application From Scratch (Build a Scalable Flask Web Project From Scratch)

Course

Creating a Scalable Flask Web Application From Scratch

In this video course, you'll explore the process of creating a boilerplate for a Flask web project. It's a great starting point for any scalable Flask web app that you wish to develop in the future, from basic web pages to complex web applications.

Title image for Add Logging and Notification Messages to Flask Web Projects (Add Logging and Notification Messages to Flask Web Projects)

Tutorial

Add Logging and Notification Messages to Flask Web Projects

After you implement the main functionality of a web project, it's good to understand how your users interact with your app and where they may run into errors. In this tutorial, you'll enhance your Flask project by creating error pages and logging messages.

Title image for Enhance Your Flask Web Project With a Database (Enhance Your Flask Web Project With a Database)

Tutorial

Enhance Your Flask Web Project With a Database

Adding a database to your Flask project elevates your web app to the next level. In this tutorial, you'll learn how to connect your Flask app to a database and how to receive and store posts from users.

Building a REST API

The lightweight nature of Flask makes the framework a valid option for building a RESTful API. While working through a multi-part project, you’ll explore HTTP requests and databases.

Title image for Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 1 (Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 1)

Tutorial

Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 1

In this three-part tutorial series, you'll create a RESTful API from scratch to keep track of people and notes using the Flask web framework. You'll also test your API with Swagger UI API documentation. In part one, you'll build the foundation of your note-keeping app.

Title image for Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 2 (Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 2)

Tutorial

Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 2

In this three-part tutorial series, you'll create a RESTful API from scratch to keep track of people and notes using the Flask web framework. You'll also test your API with Swagger UI API documentation. In part two, you'll implement a SQLite database to store your data permanently.

Title image for Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 3 (Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 3)

Tutorial

Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 3

In this three-part tutorial series, you'll create a RESTful API from scratch to keep track of people and notes using the Flask web framework. You'll also test your API with Swagger UI API documentation. In part three, you'll use SQLAlchemy to provide the functionality to add notes to a person.

Working on the Frontend

You’ve built a REST API that returns JSON, but so far nothing consumes it in a browser. Now you’ll compare Python with JavaScript, then build a JavaScript front end that talks to your Flask API. That wires the HTML and CSS you started with to the back end you just wrote.

Title image for Python vs JavaScript for Python Developers (Python vs JavaScript for Pythonistas)

Course

Python vs JavaScript for Python Developers

Python and JavaScript are two of the most popular programming languages in the world. In this course, you'll take a deep dive into the JavaScript ecosystem by comparing Python vs JavaScript. You'll learn the jargon, language history, and best practices from a Pythonista's perspective.

Title image for Build a JavaScript Front End for a Flask API (Build a JavaScript Front End for a Flask API)

Tutorial

Build a JavaScript Front End for a Flask API

Most modern websites are powered by a REST API. That way, you can separate the front-end code from the back-end logic, and users can interact with the interface dynamically. In this step-by-step tutorial, you'll learn how to build a single-page Flask web application with HTML, CSS, and JavaScript.

Deploying Your Projects

You’ve built a Flask application, connected it to a database, and given it a front end. The last step is putting it online, first by deploying a small script as a Flask app and then by deploying a full Flask project to Heroku. Once that’s done, anyone with the URL can use what you built.

Title image for Deploy Your Python Script on the Web With Flask (Python Web Applications: Deploy Your Script as a Flask App)

Course

Deploy Your Python Script on the Web With Flask

In this course, you’ll learn how to go from a local Python script to a fully deployed Flask web application that you can share with the world.

Title image for Deploying a Flask Application Using Heroku (Deploying a Python Flask Example Application Using Heroku)

Course

Deploying a Flask Application Using Heroku

Learn how to create a Python Flask example web application and deploy it using Heroku. You’ll also use Git to track changes to the code, and you’ll configure a deployment workflow with different environments for staging and production.

Congratulations on completing this learning path! You’ve gone from HTML, CSS, and Jinja templates to Flask applications backed by a database, exposed them through a REST API, wired up a JavaScript front end, and deployed the result to the web.

Continue your web development journey with the next learning path:

Learning Path

Django for Web Development

17 Resources ⋅ Skills: Django, Web Development, REST APIs, Migrations, User Management, Admin

You might also be interested in these related learning paths:

Got feedback on this learning path?

Looking for real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!

« Browse All Learning Paths