Skip to content

Instantly share code, notes, and snippets.

@jamescook
Created December 11, 2010 23:01
Show Gist options
  • Save jamescook/737707 to your computer and use it in GitHub Desktop.
Save jamescook/737707 to your computer and use it in GitHub Desktop.
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