Flask

raw JSON →
3.1.3 verified Tue May 12 auth: no python install: verified quickstart: verified

Flask is a lightweight WSGI web application framework in Python, designed with simplicity and flexibility in mind. The current version is 3.1.3, released on March 28, 2026, following a regular release cadence with feature and fix updates as needed.

pip install flask
error ModuleNotFoundError: No module named 'flask'
cause The Flask library is not installed in the Python environment where the code is being executed, or the wrong Python interpreter/virtual environment is active.
fix
Install Flask using pip: pip install Flask. If using a virtual environment, ensure it is activated before installation.
error RuntimeError: Working outside of application context
cause This error occurs when Flask functionality that relies on an active application context (like `current_app`, `g`, or database operations with extensions like Flask-SQLAlchemy) is accessed outside of a request or CLI command.
fix
Manually push an application context using with app.app_context(): around the code block that requires it.
error TypeError: The view function did not return a valid response
cause A Flask view function must return a valid response object, string, tuple, or an instance of `werkzeug.exceptions.HTTPException`. This error occurs when the function implicitly returns `None` or ends without an explicit return statement.
fix
Ensure that every execution path within a view function explicitly returns a valid Flask response, such as a string, a render_template() call, a jsonify() response, or a tuple like ('Error message', 400).
error Method Not Allowed (405 Error)
cause The HTTP method used in the client's request (e.g., POST, PUT, DELETE) is not permitted for the requested URL by the Flask route definition. By default, Flask routes only accept GET requests.
fix
Explicitly specify the allowed HTTP methods in the route decorator using the methods argument: @app.route('/my_route', methods=['GET', 'POST']).
breaking Flask 3.1.3 includes a security fix that may affect session behavior. Review the release notes for details.
fix Update your Flask application to handle session changes introduced in version 3.1.3.
gotcha Relative imports can cause issues if not used correctly. Ensure your project structure supports them to avoid ImportError.
fix Use absolute imports or adjust your project structure to support relative imports properly.
breaking The application experienced a timeout during testing. This can be caused by infinite loops, deadlocks, resource exhaustion, or long-running operations that exceed the test runner's timeout threshold.
fix Review application logs for clues about activity before the timeout. Use a debugger to identify infinite loops or deadlocks. Optimize long-running operations or increase the test runner's timeout setting if appropriate. Check for resource leaks or excessive memory/CPU usage.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.49s 22.3M
3.10 slim (glibc) - - 0.35s 23M
3.11 alpine (musl) - - 0.59s 25.0M
3.11 slim (glibc) - - 0.49s 26M
3.12 alpine (musl) - - 0.53s 16.7M
3.12 slim (glibc) - - 0.52s 17M
3.13 alpine (musl) - - 0.48s 16.3M
3.13 slim (glibc) - - 0.49s 17M
3.9 alpine (musl) - - 0.40s 22.1M
3.9 slim (glibc) - - 0.34s 23M

A minimal Flask application that renders an 'index.html' template when accessing the root URL.

from flask import Flask, render_template, request

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

if __name__ == '__main__':
    app.run(debug=True)