Skip to content

Instantly share code, notes, and snippets.

@cjgiridhar
Created August 27, 2012 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjgiridhar/3487940 to your computer and use it in GitHub Desktop.
Save cjgiridhar/3487940 to your computer and use it in GitHub Desktop.
Tornado - Escape - URL
import tornado.web
import tornado.escape
class Main(tornado.web.RequestHandler):
def get(self):
self.write("<br />")
self.write(tornado.escape.linkify("Linked URL: http://technobeans.com/2012/08/22/tornado-database-mysql-client-wrapper/"))
self.write("<br />")
self.write(tornado.escape.linkify("Short URL: http://technobeans.com/2012/08/22/tornado-database-mysql-client-wrapper/", shorten=True))
self.write("<br />")
self.write(tornado.escape.linkify("Require Protocol: www.technobeans.com/talks", require_protocol=True))
self.write("<br />")
self.write(tornado.escape.linkify("Permitted Protocol: www.technobeans.com/articles", permitted_protocols=["ftp","http"]))
self.write("<br />")
self.write(tornado.escape.squeeze("Squeezed: http://techno beans.com"))
self.write("<br />Escaped URL:")
self.write(tornado.escape.url_escape("http://techno beans.com"))
self.write("<br />Unescaped URL:")
self.write(tornado.escape.url_unescape("http%3A%2F%2Ffacebook.com"))
application = tornado.web.Application([
(r"/", Main),
],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