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

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

3. tornado.escape.linkify(text, require_protocol=True) – creates a link only if it includes a protocol like http or https or ftp

4. tornado.escape.linkify(text, permitted_protocols=[]) – creates a link only if URL belongs to permitted protocols list

5. tornado.escape.squeeze(value) – Removes all white spaces and replaces it with one white space

6. tornado.escape.url_escape(value) – Encodes the URL

7. tornado.escape.url_unescape(value,encoding=”) – Decodes given value from URL based on provided encoding