本文整理汇总了Python中werkzeug.Response.headers["X-Robots-Tag"]方法的典型用法代码示例。如果您正苦于以下问题:Python Response.headers["X-Robots-Tag"]方法的具体用法?Python Response.headers["X-Robots-Tag"]怎么用?Python Response.headers["X-Robots-Tag"]使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.Response
的用法示例。
在下文中一共展示了Response.headers["X-Robots-Tag"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: blob
# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import headers["X-Robots-Tag"] [as 别名]
def blob(ctx, rev, path):
if rev == "HEAD":
commit_obj = ctx.odb.head
elif rev == "index":
commit_obj = ctx.odb.index
if commit_obj is None:
raise NotFound("No such file or directory")
else:
commit_obj = ctx.odb.get_commit(rev)
try:
blob_obj = commit_obj.tree[path]
except KeyError:
raise NotFound("No such file or directory")
if isinstance(blob_obj, TreeObject):
# redirect to same URL with trailing "/"
return redirect(ctx.url_for("view_obj", rev=rev, path=path + "/"))
elif isinstance(blob_obj, LinkObject):
raise NotFound("No such file or directory")
if "raw" in ctx.request.args:
content_type, encoding = mimetypes.guess_type(blob_obj.name)
if content_type is None:
if "\x00" in blob_obj.data:
content_type = "application/octat-stream"
else:
content_type = "text/plain"
# TODO: use encoding
response = Response(blob_obj.data, content_type=content_type)
response.headers["X-Robots-Tag"] = "noindex"
else:
doc = render_blob(ctx, blob_obj)
response = ctx.render_to_response("blob.html", doc=doc, blob=blob_obj, commit=commit_obj)
return response