Last active
March 10, 2017 05:08
-
-
Save syfun/86a1871cae523c307814b40f36c7c8ec to your computer and use it in GitHub Desktop.
flask simple cors
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
if app.config['DEBUG']: | |
@app.after_request | |
def cors(resp): | |
resp.headers.add('Access-Control-Allow-Origin', '*') | |
resp.headers.add( | |
'Access-Control-Allow-Headers', | |
'Content-Type,Authorization,X-Foreign,X-Recursive') | |
resp.headers.add( | |
'Access-Control-Expose-Headers', | |
'Total' | |
) | |
# resp.headers.add('Access-Control-Allow-Credentials', 'true') | |
resp.headers.add('Access-Control-Allow-Methods', | |
'GET,PUT,POST,DELETE,HEAD') | |
return resp |
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
# coding=utf-8 | |
import sys | |
import re | |
from flask.cli import main | |
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment