2012-04-10 141 views
0

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

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

回答

1

你应该能够mount/到同一位置/status,地方在你的代码,你可能有可能有一条线是这样的:

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

将其更改为以下:

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

我使用的是'cherrypy.quickstart(Server(),config)'。我会研究这个'tree.mount',看看它是如何适应的。干杯。 – user124114 2012-04-11 07:45:09