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


Python HTTP_STATUS_CODES.get方法代码示例

本文整理汇总了Python中werkzeug.http.HTTP_STATUS_CODES.get方法的典型用法代码示例。如果您正苦于以下问题:Python HTTP_STATUS_CODES.get方法的具体用法?Python HTTP_STATUS_CODES.get怎么用?Python HTTP_STATUS_CODES.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.http.HTTP_STATUS_CODES的用法示例。


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

示例1: __init__

# 需要导入模块: from werkzeug.http import HTTP_STATUS_CODES [as 别名]
# 或者: from werkzeug.http.HTTP_STATUS_CODES import get [as 别名]
def __init__(self, app, path, uri=None, id=None, log=None, **options):
        self.app = app
        self.views = {}

        if log is None or isinstance(log, basestring):
            log = app.logger.manager.getLogger(log or options.get('logger_name', self.logger_name).format(app=app.name))

        super(API, self).__init__(path, uri, id, log, **options)

        self.default_mimetype = self.encoders.default.mimetype

        if self.auth and getattr(self.auth, 'log', None) is True:
            self.auth.log = log

        if log:
            log.debug(repr(self)) 
开发者ID:salsita,项目名称:flask-raml,代码行数:18,代码来源:flask_raml.py

示例2: wrap

# 需要导入模块: from werkzeug.http import HTTP_STATUS_CODES [as 别名]
# 或者: from werkzeug.http.HTTP_STATUS_CODES import get [as 别名]
def wrap(cls, exception, name=None):
        """This method returns a new subclass of the exception provided that
        also is a subclass of `BadRequest`.
        """
        class newcls(cls, exception):

            def __init__(self, arg=None, *args, **kwargs):
                cls.__init__(self, *args, **kwargs)
                exception.__init__(self, arg)
        newcls.__module__ = sys._getframe(1).f_globals.get('__name__')
        newcls.__name__ = name or cls.__name__ + exception.__name__
        return newcls 
开发者ID:jpush,项目名称:jbox,代码行数:14,代码来源:exceptions.py

示例3: name

# 需要导入模块: from werkzeug.http import HTTP_STATUS_CODES [as 别名]
# 或者: from werkzeug.http.HTTP_STATUS_CODES import get [as 别名]
def name(self):
        """The status name."""
        return HTTP_STATUS_CODES.get(self.code, 'Unknown Error') 
开发者ID:jpush,项目名称:jbox,代码行数:5,代码来源:exceptions.py

示例4: _find_exceptions

# 需要导入模块: from werkzeug.http import HTTP_STATUS_CODES [as 别名]
# 或者: from werkzeug.http.HTTP_STATUS_CODES import get [as 别名]
def _find_exceptions():
    for name, obj in iteritems(globals()):
        try:
            is_http_exception = issubclass(obj, HTTPException)
        except TypeError:
            is_http_exception = False
        if not is_http_exception or obj.code is None:
            continue
        __all__.append(obj.__name__)
        old_obj = default_exceptions.get(obj.code, None)
        if old_obj is not None and issubclass(obj, old_obj):
            continue
        default_exceptions[obj.code] = obj 
开发者ID:jpush,项目名称:jbox,代码行数:15,代码来源:exceptions.py

示例5: error_response

# 需要导入模块: from werkzeug.http import HTTP_STATUS_CODES [as 别名]
# 或者: from werkzeug.http.HTTP_STATUS_CODES import get [as 别名]
def error_response(status_code, message=None):
    """Return HTTP error code response."""
    payload = {'error': HTTP_STATUS_CODES.get(status_code, 'Unknown error')}
    if message:
        payload['message'] = message
    response = jsonify(payload)
    try:
        response.status_code = status_code.code
    except AttributeError:
        response.status_code = status_code
    return response 
开发者ID:AUCR,项目名称:AUCR,代码行数:13,代码来源:errors.py

示例6: wrap

# 需要导入模块: from werkzeug.http import HTTP_STATUS_CODES [as 别名]
# 或者: from werkzeug.http.HTTP_STATUS_CODES import get [as 别名]
def wrap(cls, exception, name=None):
        """This method returns a new subclass of the exception provided that
        also is a subclass of `BadRequest`.
        """
        class newcls(cls, exception):
            def __init__(self, arg=None, *args, **kwargs):
                cls.__init__(self, *args, **kwargs)
                exception.__init__(self, arg)
        newcls.__module__ = sys._getframe(1).f_globals.get('__name__')
        newcls.__name__ = name or cls.__name__ + exception.__name__
        return newcls 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:13,代码来源:exceptions.py

示例7: api_abort

# 需要导入模块: from werkzeug.http import HTTP_STATUS_CODES [as 别名]
# 或者: from werkzeug.http.HTTP_STATUS_CODES import get [as 别名]
def api_abort(code, message=None, **kwargs):
    if message is None:
        message = HTTP_STATUS_CODES.get(code, '')

    response = jsonify(code=code, message=message, **kwargs)
    response.status_code = code
    return response  # You can also just return (response, code) tuple 
开发者ID:greyli,项目名称:todoism,代码行数:9,代码来源:errors.py

示例8: unhandled_methods

# 需要导入模块: from werkzeug.http import HTTP_STATUS_CODES [as 别名]
# 或者: from werkzeug.http.HTTP_STATUS_CODES import get [as 别名]
def unhandled_methods(self):
        result = []
        for uri, resource in self.api.iteritems():
            methods = self.views.get(uri, ())
            result.extend((uri, method) for method in resource['methodsByName'] if method.upper() not in methods)
        return result 
开发者ID:salsita,项目名称:flask-raml,代码行数:8,代码来源:flask_raml.py

示例9: abort

# 需要导入模块: from werkzeug.http import HTTP_STATUS_CODES [as 别名]
# 或者: from werkzeug.http.HTTP_STATUS_CODES import get [as 别名]
def abort(self, status, error=None, encoder=True):
        (self.log.exception if self.app.debug and exc_info()[0] else self.log.error)(
             '%r %s %s >> %s', status, request.method, request.path,
             error or HTTP_STATUS_CODES.get(status, 'Unknown Error'))

        if error:
            return abort(status, description=error, response = self.encoders[encoder].make_response(
                dict(status=status, error=error), status=status))
        else:
            return abort(status) 
开发者ID:salsita,项目名称:flask-raml,代码行数:12,代码来源:flask_raml.py


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