【问题标题】:CherryPy index pathCherryPy 索引路径
【发布时间】:2012-04-10 20:00:56
【问题描述】:

我有一个应用程序,其中/index 路径具有特殊含义。我不希望路径 //index 同义。现在,当我访问 / 时,cherrypy 在内部将我重定向到 index 视图(对象方法)。

如何将路径/ 路由到index 以外的某个视图?例如,就我而言,我希望它与 /status 同义。

【问题讨论】:

    标签: python cherrypy


    【解决方案1】:

    你应该能够mount/ 到与/status 相同的位置,在你的代码中你可能有这样一行:

    cherrypy.tree.mount(Status(), '/status', config)
    

    将其更改为以下内容:

    status = Status()
    cherrypy.tree.mount(status, '/status', config)
    cherrypy.tree.mount(status, '/', config)
    

    【讨论】:

    • 我正在使用cherrypy.quickstart(Server(), config)。我会研究一下这个tree.mount,看看它是如何适应的。干杯。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多