skip to navigation
skip to content

Not Logged In

Flask-Cors 1.2.0

A Flask extension adding a decorator for CORS support

Latest Version: 2.0.1

Flask-CORS is a simple extension to Flask allowing you to support cross origin resource sharing (CORS) using a simple decorator.

Installation

Install the extension with using pip, or easy_install.

$ pip install flask-cors

Usage

This extension exposes a simple decorator to decorate flask routes with. Simply add @cross_origin() below a call to Flask’s @app.route(..) incanation to accept the default options and allow CORS on a given route.

Simple Usage

@app.route("/")
@cross_origin() # allow all origins all methods.
def helloWorld():
  return "Hello, cross-origin-world!"

Using defaults

Alternatively, setting your application’s CORS_ORIGINS configuration property will

app.config['CORS_ORIGINS'] = ['Foo', 'Bar']
@app.route("/")
@cross_origin() # will return CORS headers for origins 'Foo' and 'Bar'
def helloWorld():
  return "Hello, cross-origin-world!"

For a full list of options, please see the full documentation

Tests

A simple set of tests is included in test.py. To run, install nose, and simply invoke nosetests or run python test.py to exercise the tests.

Contributing

Questions, comments or improvements? Please create an issue on Github, tweet at [@wcdolphin](https://twitter.com/wcdolphin) or send me an email.

 
File Type Py Version Uploaded on Size
Flask-Cors-1.2.0.tar.gz (md5) Source 2014-03-13 9KB
  • Downloads (All Versions):
  • 1282 downloads in the last day
  • 7070 downloads in the last week
  • 30875 downloads in the last month