2012-04-10 138 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