Tornado – Options

You must have observed, all this while we have written tornado based applications that listen on port 8888, and in MySQL post, we had predefined our database connection details (like server, username, password etc). But what if we need to change these details based on modules or applications or configurations? Tornado, provides this with a … Continue reading Tornado – Options

Tornado – Escape – URLs

Like that for JSON strings, Tornado also provides methods for escaping and unescaping URLs. Not just that, it also exports some methods to play with URLs. Let's see the behavior with the example below https://gist.github.com/3487940 1. tornado.escape.linkify(text) - creates a link for provided text 2. tornado.escape.linkify(text, shorten=Tue) - creates a link and shortens the URL … Continue reading Tornado – Escape – URLs

Tornado – Escape – Json

Tornado web server exports methods for escape/unescape html, xml, Json among others. This blog discusses about encoding and decoding JSON format. Tornado has the following methods: tornado.escape.json_encode(value) - JSON'ify the Python object passed to it as argument tornado.escape.json_decode(value) - Converts the JSON string into Python Object Here's a usage example: https://gist.github.com/3478215 In this example, 1. … Continue reading Tornado – Escape – Json

Tornado – Request Handlers

In tornado, tornado.web.RequestHandler maps URLs to subclasses and tornado.web.Application class starts a server at the beginning with certain settings For instance, in the example below: When a HTTP GET request is made to http://127.0.0.1:8888/, class Hello handles it & requests made to http://127.0.0.1:8888/user are catered by class User A web formĀ  is rendered to the … Continue reading Tornado – Request Handlers