我正在尝试这个:
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()
但它一直服务于favicon.ico
我的 static_path 中有(我有两个不同的favicon.ico
位于两个单独的路径中,如上所述,但我希望能够覆盖static_path
).
Delete static_path https://github.com/tornadoweb/tornado/blob/master/tornado/web.py#L1907从应用程序设置。
然后设置你的处理程序,如下所示:
handlers = [
(r'/(favicon\.ico)', tornado.web.StaticFileHandler, {'path': favicon_path_dir}),
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_path_dir}),
(r'/', WebHandler)
]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)