Skip to main content
This tutorial will walk you through creating a basic blog application called Flaskr. Users will be able to register, log in, create posts, and edit or delete their own posts. You will be able to package and install the application on other computers.

What You’ll Build

Flaskr is a simple blog application with the following features:
  • User registration and authentication
  • Create, read, update, and delete blog posts
  • SQLite database integration
  • Template-based UI with Jinja2
  • Complete test coverage
  • Production deployment configuration

Prerequisites

It’s assumed that you’re already familiar with Python. The official Python tutorial is a great way to learn or review first.

Tutorial Structure

While Flask is flexible and doesn’t require any particular project or code layout, this tutorial uses a structured approach to avoid common pitfalls that new developers encounter. This creates a project that’s easy to expand on.
Once you become more comfortable with Flask, you can step out of this structure and take full advantage of Flask’s flexibility.
The tutorial covers:
  1. Project Layout - Set up the project structure
  2. Application Setup - Create the Flask application factory
  3. Database - Define and access the SQLite database
  4. Blueprints and Views - Create authentication and blog views
  5. Templates - Build the HTML interface with Jinja2
  6. Static Files - Add CSS styling
  7. Blog Functionality - Implement CRUD operations
  8. Make Installable - Package your application
  9. Test Coverage - Write comprehensive tests
  10. Deploy - Deploy to production

What Flask Provides

The tutorial only uses what’s provided by Flask and Python. In other projects, you might decide to use extensions or other libraries to make some tasks simpler.
The complete tutorial project is available as an example in the Flask repository if you want to compare your project with the final product.

Getting Started

Let’s begin by setting up the project structure and development environment.

Build docs developers (and LLMs) love