CORS on Flask

The following approach uses the

Python package to enable CORS in Flask.

Install the package:

$ pip install -U flask-cors

Add it to your Flask app:

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

Test by running the development server as usual:

$ flask run

For full details read the Flask-CORS package documentation.

Who’s behind this

Monsur Hossain and Michael Hausenblas


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