Typing Stubs for Flask-Cors

6.0.0.20260408 · active · verified Sat Apr 11

Typing stubs for the Flask-Cors library, enabling static type checking for Flask applications that implement Cross-Origin Resource Sharing. This package is part of the typeshed project, a central repository for type annotations, and provides accurate annotations for `Flask-Cors==6.0.*`. Typeshed packages are automatically released to PyPI as needed, often daily.

Warnings

Install

Imports

Quickstart

To use `types-flask-cors`, you first need to set up a basic Flask application with `Flask-Cors` enabled. The `types-flask-cors` package does not require any direct code changes; simply installing it allows your type checker (e.g., MyPy, Pyright) to provide static analysis for your `Flask-Cors` usage.

from flask import Flask, jsonify
from flask_cors import CORS

app = Flask(__name__)
# Enable CORS for all routes and origins
CORS(app)

@app.route("/")
def hello_world():
    return jsonify({"message": "Hello, cross-origin world!"})

@app.route("/api/data")
def get_data():
    return jsonify({"data": "This is cross-origin data."})

if __name__ == "__main__":
    # Run the app, access at http://127.0.0.1:5000/
    app.run(debug=True, port=5000)

view raw JSON →