Python Tornado 中的多个静态目录
我的目录结构设置如下:
root/
js/
css/
libs/
index.html
从 Tornado 中,我想将 js、css 和 libs 作为静态目录提供服务,但我只能找出如何提供其中之一。这可以做到吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅 https://stackoverflow.com/a/10165739/1813988
您可以通过设置处理程序来设置不同资产的静态路径像这样(并删除应用程序中的
static_path
设置):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):不,这是不可能的。
您当然可以创建一个新文件夹——parent,并将js、css和libs放入该文件夹中,然后将该父文件夹指定为“static_path”
nb。 “在生产中,您可能希望从更优化的静态文件服务器(例如 nginx)提供静态文件”
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"
正如 Schildmeijer 从 Tornado 网站引用的那样,我建议使用 Nginx 来提供静态文件。尽早进行此设置非常方便且简单。这还可以让您在未来获得一些其他潜在的好处:
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: