我想让以下网址回复
基本服务处理程序:
class Service(object):
def __init__(self):
self.book = Book()
@cherrypy.expose
def index(self):
return 'normal page'
图书类:
@cherrypy.popargs('book_name')
class Book(object):
def __init__(self):
self.page = Page()
@cherrypy.expose
@cherrypy.tools.json_out()
def index(self, book_name):
return {"book name": book_name}
@cherrypy.expose
@cherrypy.tools.json_out()
def getdetails(self, book_name):
return {"details": bookname}
Page Class:
@cherrypy.popargs('page_number')
class Page(object):
@cherrypy.expose
@cherrypy.tools.json_out()
def index(self, book_name, page_number):
return {"book": book_name, "no": page_number}
# DOES NOT WORK AS EXPEXTED
# @cherrypy.expose
# @cherrypy.tools.json_out()
# def getdetails(self, book_name, page_number):
# return {"book": book_name, "no": page_number}
@cherrypy.expose
@cherrypy.tools.json_out()
def test(self, book_name):
return {"details": "some test"}
服务是根类
if __name__ == '__main__':
cherrypy.quickstart(Service())
`