def enable_cors(func):
def _enable_cors(*args, **kwargs):
hds = response.headers
hds['Access-Control-Allow-Origin'] = '*'
hds['Access-Control-Allow-Methods'] = ', '.join(['PUT', 'GET',
'POST', 'DELETE',
'OPTIONS'])
allow = 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'
hds['Access-Control-Allow-Headers'] = allow
if request.method != 'OPTIONS':
return func(*args, **kwargs)
return _enable_cors
评论列表
文章目录