python - URL Dispatch 中路由的多个路径

标签 python url web routes pyramid

我在 Pyramid 框架中使用 URL Dispatch。据我所知,要求每条路线都有一个唯一的名称。有没有办法将多条路径与一条路线关联起来?特别是,我想让两个不同的地址显示相同的内容。注意:我不想执行重定向。

最佳答案

你的意思是这样的......

在你的配置中:

config.add_route('path::a', 'path/a')
config.add_route('path::b', 'path/b')

在你看来:

class ViewClass(handlerClass):
    @view_config(renderer="/path.mako",route_name="path::a")
    @view_config(renderer="/path.mako",route_name="path::b")
    def path(self):
        return {'project':'MyApp'}

关于python - URL Dispatch 中路由的多个路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13002255/

相关文章:

python - Django中同一模型的多个多对多关系

html - 如何使用新 URL 刷新部分内容?

javascript - ng-bind-html 未按预期工作

java - 在 Apache Wink 中声明可选命名路径参数的最佳方法是什么

apache - 如何使用托管在 Ubuntu 中的 nginx 在 docker 中启用 SSL

python - 如何更改字典中的列表?

python - 在 Jupyter Notebook 中找不到 OpenCV,但在终端中找到

python - 将数据从 excel 导入 Python 时排除第一行

Java - URI is not hierarchical 错误仅出现在导出的 JAR 中,而不出现在 Eclipse 中

javascript - 使用 JS 通过 html 按钮更改 url