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


Python HTTPResponse.status方法代码示例

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


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

示例1: apikeyNotValid

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import status [as 别名]
def apikeyNotValid():
    response = HTTPResponse()
    response.status = 200
    response.body = json.dumps(
        {
            'message': 'api key not valid',
        }
    ) + "\n"
    return response
开发者ID:nasa9084,项目名称:charakoba_fault_info,代码行数:11,代码来源:api.py

示例2: success

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import status [as 别名]
def success():
    response = HTTPResponse()
    response.status = 200
    response.body = json.dumps(
        {
            'message': 'Success'
        }
    ) + "\n"
    return response
开发者ID:nasa9084,项目名称:charakoba_fault_info,代码行数:11,代码来源:api.py

示例3: cannotTweet

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import status [as 别名]
def cannotTweet():
    response = HTTPResponse()
    response.status = 500
    response.body = json.dumps(
        {
            'message': 'Failed',
            'Error': 'CannotTweet'
        }
    ) + "\n"
    return response
开发者ID:nasa9084,项目名称:charakoba_fault_info,代码行数:12,代码来源:api.py

示例4: badRequest

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import status [as 别名]
def badRequest(key):
    response = HTTPResponse()
    response.status = 400
    response.body = json.dumps(
        {
            'message': 'Failed',
            'BadRequest': key
        }
    ) + "\n"
    return response
开发者ID:nasa9084,项目名称:charakoba_fault_info,代码行数:12,代码来源:api.py

示例5: consume

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import status [as 别名]
    def consume(self, event, *args, **kwargs):
        # There is an error that results in responding with an empty list that will cause an internal server error

        original_event_class, response_queue = self.responders.pop(event.event_id, None)

        if response_queue:

            accept = event.get('accept', original_event_class.content_type)

            if not isinstance(event, self.CONTENT_TYPE_MAP[accept]):
                self.logger.warning(
                    "Incoming event did did not match the clients Accept format. Converting '{current}' to '{new}'".format(
                        current=type(event), new=original_event_class.__name__))
                event = event.convert(self.CONTENT_TYPE_MAP[accept])

            local_response = HTTPResponse()
            status, status_message = event.status
            local_response.status = "{code} {message}".format(code=status, message=status_message)

            for header, value in event.headers.iteritems():
                local_response.set_header(header, value)

            local_response.set_header("Content-Type", event.content_type)

            if int(status) == 204:
                response_data = ""
            else:
                response_data = self.format_response_data(event)

            local_response.body = response_data

            response_queue.put(local_response)
            response_queue.put(StopIteration)
            self.logger.info("[{status}] Service '{service}' Returned in {time:0.0f} ms".format(
                service=event.service,
                status=local_response.status,
                time=(datetime.now()-event.created).total_seconds() * 1000), event=event)
        else:
            self.logger.warning("Received event response for an unknown event ID. The request might have already received a response", event=event)
开发者ID:drpoggi,项目名称:compysition,代码行数:41,代码来源:httpserver.py

示例6: jsonify

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import status [as 别名]
def jsonify(body='', status=200):
    response = HTTPResponse(content_type='application/json')
    response.body = json.dumps(body)
    response.status = status
    return response
开发者ID:terceiro,项目名称:mailman-api,代码行数:7,代码来源:utils.py

示例7: jsonify

# 需要导入模块: from bottle import HTTPResponse [as 别名]
# 或者: from bottle.HTTPResponse import status [as 别名]
def jsonify(obj, status=200):
    response = HTTPResponse(content_type='application/json')
    response.body = json.dumps(obj, encoding='latin1')
    response.status = status
    return response
开发者ID:TracyWebTech,项目名称:mailman-api,代码行数:7,代码来源:utils.py


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