本文整理汇总了Python中bottle.HTTPResponse.headers['Access-Control-Allow-Headers']方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPResponse.headers['Access-Control-Allow-Headers']方法的具体用法?Python HTTPResponse.headers['Access-Control-Allow-Headers']怎么用?Python HTTPResponse.headers['Access-Control-Allow-Headers']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bottle.HTTPResponse
的用法示例。
在下文中一共展示了HTTPResponse.headers['Access-Control-Allow-Headers']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: method_not_allowed
# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import headers['Access-Control-Allow-Headers'] [as 别名]
def method_not_allowed(res):
if request.method == 'OPTIONS':
new_res = HTTPResponse()
new_res.headers['Access-Control-Allow-Origin'] = '*'
new_res.headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS, PUT'
new_res.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept'
return new_res
res.headers['Allow'] += ', OPTIONS'
return request.app.default_error_handler(res)
示例2: _handle
# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import headers['Access-Control-Allow-Headers'] [as 别名]
def _handle(self, callback, conf, func_args, *args, **kwargs):
meth = request.method.lower()
path = request.path
filters = self._kwargs['filters']
is_pass = True
for pattern, methes in filters:
if pattern.match(path) and ((meth in methes) or ('all' in methes)):
is_pass = False
break
rv = callback(*args, **kwargs)
if is_pass:
if not isinstance(rv, HTTPResponse):
rv = HTTPResponse(rv)
rv.headers['Access-Control-Allow-Origin'] = '*'
rv.headers['Access-Control-Allow-Methods'] = \
'GET,POST,PUT,OPTIONS'
rv.headers['Access-Control-Allow-Headers'] = \
'Referer, Accept, Origin, User-Agent'
return rv