Flask

3.1.3 · active · verified Wed Mar 25

Lightweight WSGI web framework. Current version is 3.1.3 (Feb 2026). Flask 3.0 (Sep 2023) removed a large set of APIs that had been deprecated since 2.x — before_first_request, FLASK_ENV, JSON config keys, and custom json_encoder/decoder. LLMs still generate these removed patterns.

Warnings

Install

Imports

Quickstart

Minimal Flask 3.x app with JSON responses and error handler.

from flask import Flask, jsonify, request

app = Flask(__name__)

@app.get('/')
def index():
    return jsonify({'status': 'ok'})

@app.post('/items')
def create_item():
    data = request.get_json()
    return jsonify(data), 201

@app.errorhandler(404)
def not_found(e):
    return jsonify({'error': 'not found'}), 404

# Run: flask --app app run --debug

view raw JSON →