本文整理汇总了Python中werkzeug.Response.force_type方法的典型用法代码示例。如果您正苦于以下问题:Python Response.force_type方法的具体用法?Python Response.force_type怎么用?Python Response.force_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.Response
的用法示例。
在下文中一共展示了Response.force_type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: finalize_response
# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import force_type [as 别名]
def finalize_response(request, response):
"""Finalizes the response. Applies common response processors."""
if not isinstance(response, Response):
response = Response.force_type(response, request.environ)
if response.status == 200:
response.add_etag()
response = response.make_conditional(request)
before_response_sent.emit(request=request, response=response)
return response
示例2: process_view_result
# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import force_type [as 别名]
def process_view_result(self, rv):
"""Processes a view's return value and ensures it's a response
object. This is automatically called by the dispatch function
but is also handy for view decorators.
"""
if isinstance(rv, basestring):
rv = Response(rv, mimetype='text/html')
elif not isinstance(rv, Response):
rv = Response.force_type(rv, self.environ)
return rv
示例3: test_easteregg
# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import force_type [as 别名]
def test_easteregg():
"""Make sure the easteregg runs"""
req = Request.from_values('/?macgybarchakku')
resp = Response.force_type(internal._easteregg(None), req)
assert 'About Werkzeug' in resp.data
assert 'the Swiss Army knife of Python web development' in resp.data