本文整理匯總了Python中werkzeug.Response.add_etag方法的典型用法代碼示例。如果您正苦於以下問題:Python Response.add_etag方法的具體用法?Python Response.add_etag怎麽用?Python Response.add_etag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類werkzeug.Response
的用法示例。
在下文中一共展示了Response.add_etag方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __call__
# 需要導入模塊: from werkzeug import Response [as 別名]
# 或者: from werkzeug.Response import add_etag [as 別名]
def __call__(self, environ, start_response):
local.application = self
request = MongoRequest(environ)
local.url_adapter = adapter = url_map.bind_to_environ(environ)
environ['mongo.db'] = self.db
environ['mongo.fs'] = self.fs
try:
endpoint, values = adapter.match()
handler = getattr(views, endpoint)
data = handler(request, **values)
# WSGI
if callable(data):
return data(environ, start_response)
data = safe_keys(data)
data['request'] = request
# Templates
template = self.env.get_template("%s.html" % endpoint)
response = Response()
response.content_type = "text/html"
response.add_etag()
# if DEBUG:
# response.make_conditional(request)
data['endpoint'] = endpoint
response.data = template.render(**data)
except HTTPException, e:
response = e
示例2: get_resource
# 需要導入模塊: from werkzeug import Response [as 別名]
# 或者: from werkzeug.Response import add_etag [as 別名]
def get_resource(request, theme, file):
"""Returns a file from the theme."""
theme = get_theme(theme)
if theme is None:
raise NotFound()
f = theme.open_resource(file)
if f is None:
raise NotFound()
resp = Response(wrap_file(request.environ, f),
mimetype=mimetypes.guess_type(file)[0] or 'text/plain',
direct_passthrough=True)
resp.add_etag()
return resp.make_conditional(request)