Skip to main content

Flask

A lightweight WSGI web application framework for building web applications in Python

What is Flask?

Flask is a micro web framework written in Python. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja, and has become one of the most popular Python web application frameworks. Flask offers suggestions, but doesn’t enforce any dependencies or project layout. It is up to the developer to choose the tools and libraries they want to use. There are many extensions provided by the community that make adding new functionality easy.

Quick Start

Get up and running with Flask in minutes

Tutorial

Learn Flask by building a complete blog application

API Reference

Comprehensive API documentation

Extensions

Extend Flask with community packages

Key Features

Lightweight & Flexible

Flask is lightweight by design, giving you the flexibility to choose your tools and libraries without imposing dependencies or project structure.

Built-in Dev Server

Includes a development server and debugger with automatic reloading, making development fast and efficient.

Jinja2 Templating

Integrated Jinja2 templating engine for building dynamic web pages with powerful template inheritance and filters.

RESTful Routing

Clean and intuitive URL routing with support for RESTful request dispatching and URL parameters.

Secure Sessions

Cookie-based user sessions with secure signing to protect against tampering.

Blueprints

Organize your application into reusable components with blueprints for better code structure.

Testing Support

Comprehensive testing utilities for unit and integration tests to ensure your application works correctly.

Extensible

Rich ecosystem of extensions for database integration, authentication, form validation, and more.

A Simple Example

Here’s a minimal Flask application to get you started:
app.py
from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello, World!"
Run the application:
flask run
Your application will be available at http://127.0.0.1:5000/

Why Choose Flask?

Flask follows a minimalist philosophy, providing only the essential tools you need to build web applications. This makes it easy to learn and understand, especially for developers new to web frameworks.
Unlike opinionated frameworks, Flask doesn’t force you into a specific project structure or require particular tools. You have complete freedom to organize your code and choose the libraries that best fit your needs.
While Flask starts simple, it’s designed to scale. You can build everything from small prototypes to large, complex applications. The blueprint system helps you organize large codebases into manageable components.
Flask has a vibrant community that creates and maintains hundreds of extensions. Whether you need database integration, authentication, or API tools, there’s likely an extension for it.
Flask has comprehensive documentation and countless tutorials, making it easy to find help and learn best practices.

Next Steps

Installation

Install Flask and set up your development environment

Quickstart

Build your first Flask application

Tutorial

Follow a step-by-step tutorial to build a blog

Community and Support

GitHub Repository

View source code, report issues, and contribute

Discord Community

Join the Pallets Discord server for help and discussions

Build docs developers (and LLMs) love