Created
September 5, 2011 21:26
-
-
Save pamelafox/1195953 to your computer and use it in GitHub Desktop.
CORS on Python/Flask
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
from flask import request, make_response, | |
def any_response(data): | |
ALLOWED = ['http://localhost:8888'] | |
response = make_response(data) | |
origin = request.headers['Origin'] | |
if origin in ALLOWED: | |
response.headers['Access-Control-Allow-Origin'] = origin | |
return response |
Shouldn't the Access-Control-Allow-Origin
response header be always included when there's an Origin
header in the request?
Thank you very much for posting this!
Thank you for posting this.
Thanks, this was a great time-saver!
New to the concept of access-control-allow-origin, what does data take in? I assume it's the URL requesting?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gotta <3 flask