Skip to content

Instantly share code, notes, and snippets.

@waghanza
Created July 3, 2018 09:00
Show Gist options
  • Save waghanza/5fc70f9464ad77e84b04a858706d4090 to your computer and use it in GitHub Desktop.
Save waghanza/5fc70f9464ad77e84b04a858706d4090 to your computer and use it in GitHub Desktop.
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