Flask is an open-source, minimal Python web framework maintained by the Pallets Projects. It's the #11 most-used web framework overall, reported in roughly 14.4% of developer surveys. Developers reach for it because it's unopinionated โ it gives you routing and request handling and decides almost nothing else for you โ which makes it popular for small APIs and projects where the team wants full control over structure and dependencies.
A minimal Flask app maps a URL route to a Python function with a single decorator โ no project structure is enforced.
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/hello/<name>")
def hello(name):
return jsonify({"message": f"Hello, {name}!"})
@app.route("/items", methods=["POST"])
def create_item():
data = request.get_json()
return jsonify({"created": data["name"]}), 201
if __name__ == "__main__":
app.run(debug=True)
Install Flask into a virtual environment, then run the built-in development server.
# install Flask
pip install flask
# run the dev server (app.py contains `app = Flask(__name__)`)
flask --app app run --debug