Created
December 11, 2010 23:01
-
-
Save jamescook/737707 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AllowOriginMiddleware(object): | |
""" | |
Sets 'Access-Control-Allow-Origin' | |
""" | |
def __init__(self, app): | |
self.app = app | |
def __call__(self, environ, start_response): | |
def custom_start_response(status, headers, exc_info = None): | |
origin_header = ["Access-Control-Allow-Origin", "*"] | |
req_with_header = ["Access-Control-Allow-Headers", "X-Requested-With"] | |
headers.append(origin_header) | |
headers.append(req_with_header) | |
return start_response(status, headers, exc_info) | |
return self.app(environ, custom_start_response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment