Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.