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:
- Define
def default(self)
ordef index(self)
inAdminListener
(replace theadmin
method) or - Mount an instance of
AdminListener
under''
. Likecherrypy.tree.mount(adminListener, "",adminConf)
, this will have the side effect of having theadminConf
apply to all the sub-application, so I suppose the right approach would be option1
.
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"