跳转到主要内容

小型Pyramid扩展,用于重定向URL

项目描述

介绍

pyramid_redirect是一个小型扩展,用于在进一步处理之前重定向Pyramid URL。

安装

只需这样做

pip install pyramid_redirect

或者

easy_install pyramid_redirect

兼容性

pyramid_redirect与pyramid>=1.3和python>=2.7以及python>=3.5兼容。其他版本也可能工作。

文档

用法示例

def main(global_config, **settings):
    config = Configurator(settings=settings)
    config.include('pyramid_redirect')
    # add url redirecting rules...
    #   first parameter is a regular expression
    #   second parameter is the target url
    config.add_redirect_rule(r'http://example\.com/favicon.ico', r'http://example.com/static/favicon.ico')
    config.add_redirect_rule(
        r'http://example\.com/gallery/(?P<subpath>.*)',
        r'http://example.com/root/%(subpath)s',
        permanent=True,
        headers={'X-Value': 'foo'}
    )
    #
    # ... rest of configuration
    #
    # return WSGI application instance
    return config.make_wsgi_app()

查看测试以获取更多示例。

如果您使用structlog,请将以下配置设置添加到您的INI文件中,以启用类似structlog的日志记录

pyramid_redirect.structlog = true

发布

  1. 更新CHANGES.rst。

  2. 更新setup.py版本。

  3. 运行bin/longtest

  4. 运行bin/mkrelease -d pypi

我们正在招聘!

在Niteo,我们定期向开源社区贡献。如果你也在这样做,我们很乐意邀请你加入我们的团队

变更

0.4

  • 支持设置响应头。

  • 使用Black格式化代码。

  • 重命名niteoweb -> teamniteo。 [am-on]

0.3

  • 添加永久(301)重定向选项。 [am-on]

0.2

  • 支持structlog。 [zupo]

0.1.1

  • 棕色袋发布。 [zupo]

0.1

项目详情


下载文件

下载适合您平台的应用程序文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

pyramid_redirect-0.4.tar.gz (4.7 kB 查看散列)

上传时间

构建分发

pyramid_redirect-0.4-py3-none-any.whl (4.7 kB 查看散列)

上传时间 Python 3

由以下支持