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


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

本文整理汇总了Python中bottle.HTTPResponse.headers['Access-Control-Allow-Origin']方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPResponse.headers['Access-Control-Allow-Origin']方法的具体用法?Python HTTPResponse.headers['Access-Control-Allow-Origin']怎么用?Python HTTPResponse.headers['Access-Control-Allow-Origin']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bottle.HTTPResponse的用法示例。


在下文中一共展示了HTTPResponse.headers['Access-Control-Allow-Origin']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: method_not_allowed

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import headers['Access-Control-Allow-Origin'] [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: make_error

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import headers['Access-Control-Allow-Origin'] [as 别名]
def make_error(message):
    formats = {
        'json': 'application/json',
        'xml': 'application/xml',
        'jsonp': 'application/javascript',
    }
    format_ = bottle.request.query.get('format', 'json')
    response = HTTPResponse(status=message, content_type=formats[format_])
    response.headers['Access-Control-Allow-Origin'] = '*'
    return response
开发者ID:ederfranco23,项目名称:postmon,代码行数:12,代码来源:PostmonServer.py

示例3: _handle

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import headers['Access-Control-Allow-Origin'] [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-Origin']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。