作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我正在尝试这个:
favicon_path = '/path/to/favicon.ico'
settings = {'debug': True,
'static_path': os.path.join(PATH, 'static')}
handlers = [(r'/', WebHandler),
(r'/favicon.ico', tornado.web.StaticFileHandler, {'path': favicon_path})]
application = tornado.web.Application(handlers, **settings)
application.listen(port)
tornado.ioloop.IOLoop.instance().start()
但它一直为我的 static_path 中的 favicon.ico
提供服务(我在两个单独的路径中有两个不同的 favicon.ico
,如上所述,但我希望能够覆盖 static_path
中的那个)。
最佳答案
删除static_path
从应用设置。
然后将您的处理程序设置为:
handlers = [
(r'/(favicon\.ico)', tornado.web.StaticFileHandler, {'path': favicon_path_dir}),
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_path_dir}),
(r'/', WebHandler)
]
关于python - 如何从与静态路径不同的目录提供静态文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10165665/
我是一名优秀的程序员,十分优秀!