Last active
August 29, 2015 14:11
-
-
Save ls0f/8be68a3266601f872832 to your computer and use it in GitHub Desktop.
tornado hack static url in template html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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