Skip to content

Instantly share code, notes, and snippets.

@cjgiridhar
Created July 27, 2012 08:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjgiridhar/3186793 to your computer and use it in GitHub Desktop.
Save cjgiridhar/3186793 to your computer and use it in GitHub Desktop.
Tornado - Redirection
<html>
<body>
<FORM ACTION="/article" METHOD=POST>
<input type="submit" value="Home">
</FORM>
</body>
</html>
import tornado.ioloop
import tornado.web
import time
class ItWorks(tornado.web.RequestHandler):
def get(self):
self.write("It Works!!")
class About(tornado.web.RequestHandler):
def get(self):
self.write("This is a tutorial on Tornado. Enjoy!")
class Article(tornado.web.RequestHandler):
def get(self):
self.write("Page on articles")
self.render("home.html") ## Button
def post(self):
self.redirect("/")
application = tornado.web.Application([
(r"/", ItWorks),
(r"/article", Article),
(r"/about", About),
],debug=True)
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