Instantly share code, notes, and snippets.

Embed
What would you like to do?
from datetime import date
import tornado.ioloop
import tornado.web
class VersionHandler(tornado.web.RequestHandler):
def get(self):
response = {
'version': '1.0.0',
'last_build': date.today().isoformat()
}
self.write(response)
class GetUser(tornado.web.RequestHandler):
def get(self, id, user_name):
response = {
'id': int(id),
'user_name': user_name
}
self.write(response)
application = tornado.web.Application([
(r"/getuser/([0-9]+)/(.+)", GetUser),
(r"/version", VersionHandler)
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment