Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Static Directories in Python Tornado

Tags:

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 to serve one of them. Can this be done?

like image 679
Bain Markev Avatar asked May 23 '26 21:05

Bain Markev


1 Answers

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)
]
like image 193
phil Avatar answered May 26 '26 10:05

phil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!