Skip to content

Instantly share code, notes, and snippets.

@ls0f
Last active August 29, 2015 14:11
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 ls0f/8be68a3266601f872832 to your computer and use it in GitHub Desktop.
Save ls0f/8be68a3266601f872832 to your computer and use it in GitHub Desktop.
tornado hack static url in template html
def static_url_patch():
from tornado.template import Template
old_generate = Template.generate
def hack_generate(self,**kwargs):
t = old_generate(self,**kwargs)
import re
print "hack generate"
t = re.sub(r'(?<=[\'|"])/static/',r'http://example.com/static/',t)
return t
tornado.template.Template.generate = hack_generate
static_url_patch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment