Nodea — logo

Flask

Flask is a lightweight web microframework for the Python language, used to build web applications and APIs. The term microframework means the tool provides only the core needed to handle HTTP requests and routing, while the rest of the components — the database layer, authentication or validation — are chosen by the developer from a wide range of extensions. This philosophy gives great freedom and makes Flask valued for its simplicity and low barrier to entry.

How Flask works

Flask is built on the Werkzeug library (WSGI and HTTP request handling) and the Jinja2 template engine (generating HTML pages). The developer defines routes, mapping URLs to Python functions that return a response — HTML markup, JSON data for an API or a redirect. The framework passes an incoming request to the appropriate function and sends its result back to the browser. Thanks to a built-in development server, an application can be launched locally in just a few lines of code.

Extensions

Flask's ecosystem is built around extensions that add specific features: SQLAlchemy for database access, Flask-Login for user sessions or Flask-RESTful for building APIs. This lets the framework scale from a simple script to a full-featured application.

Practical applications

Flask is a popular choice for building APIs, microservices, admin panels and applications for analytics and machine learning, where it naturally connects with Python's data-science ecosystem. Flask applications are deployed on servers running a WSGI server (such as Gunicorn) behind a reverse proxy like Nginx. For production hosting, a VPS works well, giving full control over the Python environment and the project's dependencies.

Powiązane pojęcia

Najczęstsze pytania

How is Flask different from Django?

Flask is a microframework — it provides a minimum of functionality and lets you choose your own components, such as the database layer. Django is a full-stack framework with a built-in ORM, admin panel and many ready-made mechanisms. Flask offers more freedom, Django more out-of-the-box solutions.

What is Flask best suited for?

Flask is excellent for building APIs, microservices, prototypes and smaller web applications where flexibility and light weight matter. Thanks to extensions it can scale to larger projects by adding only the components you actually need.