Trouble accessing favicon or css or other web page images with Tornado?
Well here’s the solution. Tornado provides tornado.web.StaticFileHandler construct that helps the web server locate images or icon files to be served while loading the web page. Here’s an example
https://gist.github.com/3205067.js
In this example, articles.html is loading images/images.jpg. Path images/* is understood by Tornado with the statement
(r”/images/(.*)”,tornado.web.StaticFileHandler, {“path”: “./images”},),
What if, we make a slight change here, negation with ‘^’? This would mean, Tornado Web Server shouldn’t load anything under images directory. Convenient!
(r”/images/^(.*)”,tornado.web.StaticFileHandler, {“path”: “./images”},),
Please note you may face permission issues while loading content like .html, .css files. Ensure they have correct permissions to be accessed from Tornado
Thanks a lot! It was really useful for me to get it working 🙂
Thank so mush. very helpful for me.