Tornado – Redirection


Redirections are essential while developing a website. What if you need to redirect a user from a page to home page based on an event? Tornado supports redirection.

In the example below,

  • When you run tornadoredirection.py and open a browser at http://127.0.0.1:8888, you would notice a message, ‘It Works!’ which suggests Tornado Web Server is up and running.
  • On browsing to http://127.0.0.1:8888/article (HTTP GET), you would notice message ‘Page on articles’ with a button ‘Home’.
  • Button ‘Home’ is a html file that submits a Post request on ‘/article’ page. Class Article  handles this HTTP POST request and redirects itself to home page(‘/’).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s