CORS on Flask

The following approach uses the

Flask-CORS
Python package to enable CORS in Flask.

Install the package:

$ pip install -U flask-cors

Add it to your Flask app:

# app.py
from flask import Flask
from flask_cors import CORS
app = Flask(__name__)
cors = CORS(app)

Test by running the development server as usual:

$ FLASK_APP=app.py flask run

For full details read the Flask-CORS package documentation.

Who’s behind this

Monsur Hossain and Michael Hausenblas

Contribute

The content on this site stays fresh thanks to help from users like you! If you have suggestions or would like to contribute, fork us on GitHub.

Buy the book

Save 39% on CORS in Action with promotional code hossainco at manning.com/hossain