Skip to content

Instantly share code, notes, and snippets.

@andreadipersio
Last active December 28, 2015 16:09
Show Gist options
  • Save andreadipersio/7526691 to your computer and use it in GitHub Desktop.
Save andreadipersio/7526691 to your computer and use it in GitHub Desktop.
import tornado.ioloop
import tornado.web
# http://www.tornadoweb.org/en/stable/options.html
from tornado.options import parse_command_line, define, options
define("port", default=8888)
define("debug", default=False)
class MainHandler(tornado.web.RequestHandler):
def get(self):
# http://www.tornadoweb.org/en/branch3.1/web.html#tornado.web.RequestHandler.write
self.write({"directives": [(1, "serve the public trust"),
(2, "protect the innocent"),
(3, "uphold the law"),
(4, "classified")]})
handlers = [
(r"/", MainHandler),
]
if __name__ == "__main__":
parse_command_line()
application = tornado.web.Application(handlers, debug=options.debug)
application.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment