Skip to content

Instantly share code, notes, and snippets.

@elebertus
Created January 25, 2014 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elebertus/8624691 to your computer and use it in GitHub Desktop.
Save elebertus/8624691 to your computer and use it in GitHub Desktop.
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