Search code examples
pythoncherrypy

CherryPy index path


I have an app where the /index path has a special meaning. I don't want path / to be synonymous with /index. Right now, when I access /, cherrypy internally redirects me to the index view (object method).

How do I route the path / to some view other than index? For example, in my case, I want it to be synonymous to /status.


Solution

  • You should be able to mount / to the same location as /status, somewhere in your code you probably have may have a line something like this:

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

    Change it to the following:

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