当前位置: 首页>>代码示例>>Python>>正文


Python Response.headers["X-Robots-Tag"]方法代码示例

本文整理汇总了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
开发者ID:nakamuray,项目名称:blikit,代码行数:42,代码来源:views.py


注:本文中的werkzeug.Response.headers["X-Robots-Tag"]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。