flask
The Python micro framework for building web applications.
Flask is a minimal Python web framework that lets you build websites and APIs in just a few lines of code, handling the low-level web plumbing so you can focus on your app's logic.
Flask is a lightweight Python web framework for building web applications and APIs. The problem it solves is making it fast and simple to get a working web server running in Python with minimal setup. A web framework handles the low-level plumbing of web communication (receiving HTTP requests, routing them to the right function, sending back responses) so you can focus on writing the actual application logic. Flask takes a minimalist approach: it gives you the core tools but does not force any particular database, authentication library, or project structure on you.
Flask works by letting you define URL routes as Python functions decorated with a simple annotation. When a request arrives at a given URL path, Flask calls the matching function and returns whatever it produces as the HTTP response. Under the hood it uses Werkzeug (a WSGI toolkit that handles the actual HTTP layer, where WSGI is the standard interface between Python web apps and web servers) and Jinja (a templating engine for generating HTML pages dynamically). Flask follows the WSGI standard, meaning it works with any compliant web server. Extensions from the community add features like database integration, form validation, and authentication when needed.
You would use Flask when you want to build a Python web application or REST API without the overhead of a larger framework like Django. It is well suited for small-to-medium APIs, prototypes, microservices, and projects where you want to pick your own stack. The minimal example in the README is just five lines of Python: create an app, define a route function, and run. The tech stack is Python 3, with Werkzeug and Jinja as core dependencies. It is maintained by the Pallets open-source organization.
Where it fits
- Build a REST API for a mobile or frontend app by defining routes as Python functions with simple decorators.
- Create a web dashboard or admin panel that reads from a database and renders HTML pages with templates.
- Prototype a small web service quickly without committing to a larger, more opinionated framework.
- Build a microservice that handles one specific task and exposes it over HTTP with minimal setup.