本文整理匯總了Python中werkzeug.Response.headers['Access-Control-Allow-Headers']方法的典型用法代碼示例。如果您正苦於以下問題:Python Response.headers['Access-Control-Allow-Headers']方法的具體用法?Python Response.headers['Access-Control-Allow-Headers']怎麽用?Python Response.headers['Access-Control-Allow-Headers']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類werkzeug.Response
的用法示例。
在下文中一共展示了Response.headers['Access-Control-Allow-Headers']方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_subscribe
# 需要導入模塊: from werkzeug import Response [as 別名]
# 或者: from werkzeug.Response import headers['Access-Control-Allow-Headers'] [as 別名]
def on_subscribe(self, request):
if request.method == "OPTIONS":
# Handle cross-domian ajax
response = Response()
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'GET'
response.headers['Access-Control-Allow-Headers'] = 'last_modified,if-modified-since,x-requested-with'
response.headers['Access-Control-Max-Age'] = 86400
return response
else:
# Handle a normal request
last_modified = local.last_modified = request.headers.get('last_modified', None)
if last_modified is None:
last_modified = local.last_modified = request.headers.get('If-Modified-Since', None)
channel = request.args.get('channel', None)
if channel is not None:
if last_modified is not None:
last_modified = parse_timestr(last_modified)
last_modified += timedelta(seconds=1)
local.next_update = next_update = self.get_next_update(channel, last_modified)
while (next_update is None):
time.sleep(1)
next_update = self.get_next_update(channel, last_modified)
response = self.send_update(next_update)
else:
response = Response(response="A channel get param must be passed.", status=400)
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'GET'
response.headers['Access-Control-Allow-Headers'] = 'last_modified,if-modified-since,x-requested-with'
response.headers['Access-Control-Max-Age'] = 86400
return response