Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable template processing in Tornadoweb

I have to use Tornadoweb as RESTfull backend for our existing AngularJs application.

The {{}} are heavily used in the angular app. I would like to serve angular files from tornado as static files

Is there a way to disable processing templates by tornado to avoid conflicts with {{}} used by tornado?

I know how to change the {{}} in the angular app with $interpolateProvider but it will involve a lot of changes in the angular app.

As a temporary solution, I put the angular app in the static folder of tornado and used a redirect:

class IndexHandler(RequestHandler):
    def get(self):
        self.redirect(self.static_url('ng-app/index.html'),True)

It is working but it is not a nice solution because The url displayed is some thing like :

http://localhost:8080/static/ng-app/index.html?v=efb937e6a0cb0739eb0edfd88cfb4844

Any better idea?

Thank you in advance

like image 896
med Avatar asked Jun 24 '13 20:06

med


Video Answer


2 Answers

Use {{!tag}} to disable the translation of tornado.

like image 98
Speq Avatar answered Sep 20 '22 05:09

Speq


You can use Tornado's built in StaticFileHandler. This passes everything as static files to Angular:

from tornado import options, ioloop, web

options.define("port", default=8888, help="run on the given port", type=int)

SETTINGS = {
    "debug" : True
}

application = web.Application([
    (r'/(.*)', web.StaticFileHandler, {"path": "angular_app"})
],**SETTINGS)


if __name__ == "__main__":
    options.parse_command_line()
    application.listen(options.options.port)
    ioloop.IOLoop.instance().start()
like image 41
samuel5 Avatar answered Sep 22 '22 05:09

samuel5