Flask Introduction
Flask is a lightweight Python web application framework, developed and maintained by the Pallets organization.
It is known for being simple and flexible, letting you quickly get started building web applications while still having the ability to scale to complex projects.

Flask is a micro web framework developed in Python. It is called a microframework mainly because it does not bundle any specialized tools or dependency libraries, and does not natively include common web components such as a database abstraction layer or form validation.
Flask has good extension support, allowing you to add functional plugins as needed. There are mature extensions for ORM (object-relational mapping), form validation, file uploads, open authentication, and various supporting development tools, which can fill in the functionality your project requires.
What Is Flask
Flask is a WSGI (Web Server Gateway Interface) web application framework.
WSGI is a standard interface defined by Python that specifies how web servers communicate with Python web applications. You can think of it as the 'universal socket' of the Python web world.
Flask originally was just a simple wrapper layer around Werkzeug and Jinja, and has now become one of the most popular web frameworks in the Python community.
Core dependency
When you install Flask, the following dependencies are automatically installed, each with its own role:
| Dependency Library | Purpose | When You'll Encounter It |
|---|---|---|
| Werkzeug | WSGI utility library, responsible for HTTP request parsing, response wrapping, and URL routing matching | When handling requests and returning responses, Werkzeug is working under the hood |
| Jinja2 | Template engine, responsible for rendering data into HTML pages | When using render_template() to generate dynamic pages |
| Click | Command-line tool framework, providing the flask terminal command | When running flask run or custom CLI commands |
| itsdangerous | Data signing library, ensuring data integrity is not tampered with | Signature verification of Session cookies |
| blinker | Signals mechanism, allowing callbacks to be triggered when specific events occur | When you want to execute custom logic at the start/end of a request |
Understanding and Memorization: Think of Flask as a car: Werkzeug is the engine (core power), Jinja2 is the interior (what users see), Click is the steering wheel (how you control it), and itsdangerous is the seat belt (safety guarantee).
Flask's Design Philosophy
Flask's two core concepts determine how it is used.
Microframework, Not Micro Capabilities
Flask's core is very lean, but through its rich extension ecosystem it can meet almost any need.
It does not force you to use a specific database, form library, or project structure—developers choose the tools that best suit them.
This design means: small projects are not weighed down by the framework, while large projects can be assembled as needed.
Explicit Is Better Than Implicit
Unlike some 'batteries-included' frameworks, Flask doesn't secretly do a lot of things for you.
Every feature needs to be explicitly imported and configured by you, which may require a few more lines of code when you're starting out, but gives you complete control over the project.
If you've used Django before, you might feel that Flask 'makes you do everything yourself.' That is exactly Flask's design intent: to let you clearly know where every feature comes from.
Flask Features
-
Lightweight and Concise: Flask is a microframework that provides the most basic features and does not force the use of any specific tools or libraries. Its core is simple and flexible, allowing developers to add features as needed.
-
Flexibility: Flask provides a basic framework structure, but has no mandatory project layout or components; developers can customize according to their needs.
-
Extensibility: Flask's design allows you to add features through plugins and extensions. Many common features, such as form handling, database interaction, and user authentication, can be implemented through community-provided extensions.
-
Built-in Development Server: Flask includes a built-in development server, making it convenient to debug and test locally.
-
RESTful Support: Flask supports the development of RESTful APIs, making it suitable for building modern web services and applications.
If you've used Django before, you might feel that Flask 'makes you do everything yourself.' That is exactly Flask's design intent: to let you clearly know where every feature comes from and have complete control over the project.
Flask Use Cases
-
Small Projects: For small personal or startup projects, Flask's simplicity and flexibility enable quick startup and iteration.
-
Rapid Prototyping: In the early stages of product development, Flask can be used to quickly build prototypes and validate concepts and user interfaces.
-
Microservices: In a microservices architecture, Flask can be used to build independent, lightweight service components.
-
API Development: Flask is well suited for developing RESTful APIs, because its routing system is simple and clear, making it easy to define API endpoints.
-
Education and Learning: Due to its ease of use, Flask is an excellent tool for learning web development and Python programming.
-
Internal Tools: Flask can be used to develop tools or dashboards for internal company use, which usually do not require complex user interfaces.
-
Plugins or Extensions: Flask can serve as a plugin or extension for other large frameworks, providing specific functionality.
-
Custom Web Applications: For web applications requiring a high degree of customization, Flask provides enough flexibility to meet specific needs.
-
Data visualization: Flask can be combined with data visualization libraries (such as Bokeh or Plotly) to create interactive data visualization web applications.
-
Scientific Computing and Data Analysis: Flask can be combined with scientific computing libraries (such as NumPy and Pandas) to develop web applications for data analysis and scientific computing.
-
Lightweight CMS: Flask can be used to build lightweight content management systems, especially when a high degree of customization is needed.
-
Web Scraping: Flask can serve as the backend for web scraping projects, handling data scraping and API requests.
Flask's Components
/Users/tianqixin/runoob-test/runoob-article/2026-05-13/images/flask-architecture.svg
-
Flask Application Instance: The core of Flask is the application instance; the application is initialized by creating a Flask object.
-
Routes and View Functions: Routes map URLs to view functions, which handle requests and return responses.
-
Template System: Flask uses the Jinja2 template engine to render HTML pages, dynamically inserting data into the page.
-
Requests and Responses: Flask handles HTTP requests and generates responses, supporting multiple HTTP methods (such as GET and POST).
Technology Stack Overview
The following diagram shows the typical layered structure of a Flask application, helping you understand the position of each component as a whole: