Created
September 23, 2014 03:39
-
-
Save val314159/d448af5cc4111bc5de2d to your computer and use it in GitHub Desktop.
This file contains 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
''' | |
small util lib for cors handling (in bottle) | |
''' | |
def add_headers(response): | |
''' | |
call this to slap the proper CORS headers into any dict-like object | |
''' | |
#allow_methods = ', '.join(['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'OPTIONS']) | |
allow_methods = ', '.join(['GET', 'HEAD', 'POST', 'OPTIONS']) | |
allow_headers = ', '.join(['Origin', 'X-Requested-With', 'Content-Type', | |
'Accept', 'Authorization', 'Access-Token']) | |
response.headers['Access-Control-Allow-Credentials'] = 'true'; | |
#response.headers['Access-Control-Allow-Origin']='http://url:8080' | |
response.headers['Access-Control-Allow-Origin' ] = '*' | |
response.headers['Access-Control-Allow-Methods' ] = allow_methods | |
response.headers['Access-Control-Allow-Headers' ] = allow_headers | |
return ['OK'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment