当前位置: 首页>>代码示例>>Python>>正文


Python HTTPResponse.headers['Access-Control-Allow-Headers']方法代码示例

本文整理汇总了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)
开发者ID:phylotastic,项目名称:phylo_webservices,代码行数:11,代码来源:webapi.py

示例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
开发者ID:armersong,项目名称:bottle-web-seed,代码行数:21,代码来源:cross_domain_filter.py


注:本文中的bottle.HTTPResponse.headers['Access-Control-Allow-Headers']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。