How to serve static files from a different directory than the static path?
You need to wrap favicon.ico with parenthesis and escape the period in the regular expression. Your code will become
favicon_path = '/path/to/favicon.ico' # Actually the directory containing the favicon.ico file
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()
Delete static_path
from the app settings.
Then set your handler like:
handlers = [
(r'/(favicon\.ico)', tornado.web.StaticFileHandler, {'path': favicon_path_dir}),
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_path_dir}),
(r'/', WebHandler)
]