Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Makes it easier to add CORS support to tornado apps.
Python
branch: master

This branch is 23 commits behind globocom:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
tornado_cors
.gitignore
.travis.yml
MANIFEST.in
Makefile
README.md
requirements.local.txt
requirements.txt
setup.py

README.md

Tornado CORS Build Status

Makes it easier to add CORS support do tornado apps.

About Cross-Origin Resource Sharing (CORS)

Installing

pip install tornado-cors

Using

class MyHandler(CorsMixin, RequestHandler):

    # Value for the Access-Control-Allow-Origin header.
    # Default: None (no header).
    CORS_ORIGIN = '*'

    # Value for the Access-Control-Allow-Headers header.
    # Default: None (no header).
    CORS_HEADERS = 'Content-Type'

    # Value for the Access-Control-Allow-Methods header.
    # Default: Methods defined in handler class.
    # None means no header.
    CORS_METHODS = 'POST'

    # Value for the Access-Control-Max-Age header.
    # Default: 86400.
    # None means no header.
    CORS_MAX_AGE = 21600

    ...

Advanced

By default, CorsMixin defines "options" method using the decorator "asynchronous" from "tornado.web".

If your project customizes this decorator for some purpose (eg. usage of greenlets), CorsMixin allows such customization in options wrapper.

Usage:

# custom_wrapper was previously defined

from tornado_cors import custom_decorator
custom_decorator.wrapper = custom_wrapper

License

Tornado CORS is licensed under the MIT License:

The MIT License

Copyright (c) 2013 globo.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.