Skip to content

Instantly share code, notes, and snippets.

@syfun
Last active March 10, 2017 05:08
Show Gist options
  • Save syfun/86a1871cae523c307814b40f36c7c8ec to your computer and use it in GitHub Desktop.
Save syfun/86a1871cae523c307814b40f36c7c8ec to your computer and use it in GitHub Desktop.
flask simple cors
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
# 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