Skip to content Skip to sidebar Skip to footer

404 For Path Served By Cherrypy

For three simple apps: let us use a different port than 8080: cherrypy.config.update({'server.socket_host': '127.0.0.1', 'server.socket_port': 28130

Solution 1:

The AdminListener class is mounted under /admin and AdminListener does not have a default or index method to be able to mount an instance of AdminListener under /admin and expect it to work. For instance, with your current implementation/admin/admin should work.

You can either:

  1. Define def default(self) or def index(self) in AdminListener (replace the admin method) or
  2. Mount an instance of AdminListener under ''. Like cherrypy.tree.mount(adminListener, "",adminConf), this will have the side effect of having the adminConf apply to all the sub-application, so I suppose the right approach would be option 1.

For example, for option 1:

classAdminListener(object):
      @cherrypy.exposedefindex(self, param=None):
          return"Hello from Admin"

alternatively

classAdminListener(object):
      @cherrypy.exposedefdefault(self, param=None):
          return"Hello from Admin"

The main difference is that the index method does not consume url fragments like positional parameters, for example /admin/one would not work, but /admin/?param=one will work with index and default (notice the second /, is important).

The default method is like a catch-all alternative, it will be called for any undefined path under the mountpoint of the app.

Post a Comment for "404 For Path Served By Cherrypy"