本文整理汇总了Python中werkzeug.wrappers.Response.headers["Content-encoding"]方法的典型用法代码示例。如果您正苦于以下问题:Python Response.headers["Content-encoding"]方法的具体用法?Python Response.headers["Content-encoding"]怎么用?Python Response.headers["Content-encoding"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.wrappers.Response
的用法示例。
在下文中一共展示了Response.headers["Content-encoding"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_post_response
# 需要导入模块: from werkzeug.wrappers import Response [as 别名]
# 或者: from werkzeug.wrappers.Response import headers["Content-encoding"] [as 别名]
def create_post_response(self, request, result):
response = Response()
accepts_gzip = 0
try:
if request.environ.get("HTTP_ACCEPT_ENCODING").find("gzip") != -1:
accepts_gzip = 1
except:
pass
buff = json.dumps(result, default=common.json_defaul_handler)
response.headers["Content-Type"] = "application/json"
if accepts_gzip:
buff = common.compressBuf(buff)
response.headers["Content-encoding"] = "gzip"
response.headers["Content-Length"] = str(len(buff))
response.set_data(buff)
return response