【发布时间】:2013-08-15 14:43:28
【问题描述】:
这是我第一次使用 CherryPy,请原谅我的愚蠢行为。
我正在尝试编写一个 RESTful API,部分处理添加/删除人员。我希望能够 GET/PUT/DELETE example.com/people/。
对于索引方法和定义的函数,调度程序的行为似乎完全不同:
class people:
"""This is the class for CherryPy that deals with 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)
如果我调用 example.com/people/tom,我会得到 404,如果我调用 example.com/people/who/tom,我会得到 'tom' 返回。
谁能看到我做错了什么?有没有办法可以将 /xxx 传递给索引?
【问题讨论】: