Created
July 3, 2018 09:00
-
-
Save waghanza/5fc70f9464ad77e84b04a858706d4090 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.httpserver | |
import tornado.ioloop | |
import tornado.web | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.write('') | |
class UserHandler(tornado.web.RequestHandler): | |
def post(self): | |
self.write('') | |
class UserInfoHandler(tornado.web.RequestHandler): | |
def get(self, id): | |
self.write(id) | |
if __name__ == '__main__': | |
app = tornado.web.Application(handlers=[(r'/', MainHandler), | |
(r"/user", UserHandler), | |
(r"/user/(\d+)", UserInfoHandler)]) | |
http_server = tornado.httpserver.HTTPServer(app) | |
http_server.bind(3000, address='0.0.0.0', reuse_port=True) | |
http_server.start(0) | |
tornado.ioloop.IOLoop.current().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment