Created
August 6, 2012 14:11
-
-
Save cjgiridhar/3274687 to your computer and use it in GitHub Desktop.
Tornado - POST Request Handler
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.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() |
This is a nice example.
This really helped thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice hello world