app.py 453 B

123456789101112131415161718
  1. #!/usr/bin/env python
  2. import cherrypy
  3. class CherryPyBenchmark(object):
  4. @cherrypy.expose
  5. @cherrypy.tools.json_out()
  6. def json(self):
  7. cherrypy.response.headers["Content-Type"] = "application/json"
  8. json_message = {"message": "Hello, world!"}
  9. return json_message
  10. @cherrypy.expose
  11. def plaintext(self):
  12. return "Hello, world!"
  13. if __name__ == "__main__":
  14. cherrypy.quickstart(CherryPyBenchmark())