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

source

however, url of example.com/people?name=tom should work expect.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -