本文整理汇总了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
示例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
示例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
示例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
示例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)
示例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
示例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