Skip to content

Instantly share code, notes, and snippets.

@cjgiridhar
Created August 6, 2012 14:11
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cjgiridhar/3274687 to your computer and use it in GitHub Desktop.
Save cjgiridhar/3274687 to your computer and use it in GitHub Desktop.
Tornado - POST Request Handler
import tornado.ioloop
import tornado.web
class Hello(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
class User(tornado.web.RequestHandler):
def get(self):
form = """<form method="post">
<input type="text" name="username"/>
<input type="text" name="designation"/>
<input type="submit"/>
</form>"""
self.write(form)
def post(self):
username = self.get_argument('username')
designation = self.get_argument('designation')
self.write("Wow " + username + " you're a " + designation)
application = tornado.web.Application([
(r"/", Hello),
(r"/user/", User),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
@alejandrogallo
Copy link

nice hello world

@y19818
Copy link

y19818 commented Aug 17, 2022

This is a nice example.

@maroberts82
Copy link

This really helped thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment