接收json
class Root(object): @cherrypy.expose @cherrypy.tools.json_in() def index(self): data = cherrypy.request.json print(data)
返回json
import cherrypy class Root(object): @cherrypy.expose @cherrypy.tools.json_out() def index(self): return {'key': 'value'} if __name__ == '__main__': cherrypy.quickstart(Root())