Last active
December 28, 2015 16:09
-
-
Save andreadipersio/7526691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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