python - Cherrypy index dispatcher not like defined -
this first outing cherrypy forgive stupidity.
i'm trying write restful api in part deals adding/removing people. want able get/put/delete example.com/people/.
the dispatcher seems behaving totally differently index method vs defined function:
class people: """this class cherrypy deals crud on people""" @cherrypy.expose def index(self, name): return name @cherrypy.expose def who(self, name): return name root = webroot() root.people = people() cherrypy.quickstart(root)
if call example.com/people/tom, 404, if call example.com/people/who/tom 'tom' returned.
can see i'm doing wrong? there way can pass /xxx index?
indexes bit different when comes url arguments.
the index method has special role in cherrypy: handles intermediate uri’s end in slash; example, uri /orders/items/ might map root.orders.items.index. index method can take additional keyword arguments if request includes querystring or post params; see keyword arguments, next. however, unlike other page handlers, cannot take positional arguments
however, url of example.com/people?name=tom
should work expect.
Comments
Post a Comment