eventman_server.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python
  2. """Event Man(ager)
  3. Your friendly manager of attendants at a conference.
  4. """
  5. import os
  6. import tornado.httpserver
  7. import tornado.ioloop
  8. import tornado.options
  9. from tornado.options import define, options
  10. import tornado.web
  11. class MainHandler(tornado.web.RequestHandler):
  12. def get(self):
  13. self.write("Hello, world")
  14. def main():
  15. define("port", default=5242, help="run on the given port", type=int)
  16. define("config", help="read configuration file",
  17. callback=lambda path: tornado.options.parse_config_file(path, final=False))
  18. define("debug", default=False, help="run in debug mode")
  19. tornado.options.parse_command_line()
  20. application = tornado.web.Application([
  21. (r"/", MainHandler),
  22. ],
  23. static_path=os.path.join(os.path.dirname(__file__), "static"),
  24. debug=options.debug
  25. )
  26. http_server = tornado.httpserver.HTTPServer(application)
  27. http_server.listen(options.port)
  28. tornado.ioloop.IOLoop.instance().start()
  29. if __name__ == '__main__':
  30. main()