Multiple Static Directories In Python Tornado
I have a directory structure setup like: root/ js/ css/ libs/ index.html From Tornado, I want to serve js, css, and libs as static directories, but I can only find out how
Solution 1:
See https://stackoverflow.com/a/10165739/1813988
You can set the static path for different assets by setting handlers like this (and remove the static_path
setting in Application):
handlers = [
(r'/favicon.ico', tornado.web.StaticFileHandler, {'path': favicon_path}),
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_path}),
(r'/', WebHandler)
]
Solution 2:
No its not possible.
You could ofcourse create a new folder -- parent, and place js, css and libs inside of that folder, and then speciy that parent folder as the 'static_path'
nb. "In production, you probably want to serve static files from a more optimized static file server like nginx"
Solution 3:
As Schildmeijer quoted from the Tornado website, I recommend using Nginx to serve static files. Having this setup early on is very convenient and easy. This also allows you some other potential benefits in the future:
- Using Nginx for load balancing
- Using Nginx to handle SSL
Post a Comment for "Multiple Static Directories In Python Tornado"