From 18a1681a61577b3ee4c36d3b4c80069ccc39c53e Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 17 Jun 2014 09:33:45 -0700 Subject: [PATCH] Fixed issue with facicon.ico file and static link being incorrect causing 404 errors. --- sickbeard/webserveInit.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sickbeard/webserveInit.py b/sickbeard/webserveInit.py index 5472c3a5..91c3e93a 100644 --- a/sickbeard/webserveInit.py +++ b/sickbeard/webserveInit.py @@ -13,6 +13,7 @@ from tornado.ioloop import IOLoop server = None + class MultiStaticFileHandler(StaticFileHandler): def initialize(self, paths, default_filename=None): self.paths = paths @@ -33,6 +34,7 @@ class MultiStaticFileHandler(StaticFileHandler): # Oops file not found anywhere! raise HTTPError(404) + def initWebServer(options={}): options.setdefault('port', 8081) options.setdefault('host', '0.0.0.0') @@ -115,13 +117,15 @@ def initWebServer(options={}): # Static Path Handler app.add_handlers(".*$", [ - ('%s/%s/(.*)([^/]*)' % (options['web_root'], 'images'), MultiStaticFileHandler, + (r'/(favicon\.ico)', MultiStaticFileHandler, + {'paths': '%s/%s' % (options['web_root'], 'images/ico/favicon.ico')}), + (r'%s/%s/(.*)(/?)' % (options['web_root'], 'images'), MultiStaticFileHandler, {'paths': [os.path.join(options['data_root'], 'images'), os.path.join(sickbeard.CACHE_DIR, 'images'), os.path.join(sickbeard.CACHE_DIR, 'images', 'thumbnails')]}), - ('%s/%s/(.*)([^/]*)' % (options['web_root'], 'css'), MultiStaticFileHandler, + (r'%s/%s/(.*)(/?)' % (options['web_root'], 'css'), MultiStaticFileHandler, {'paths': [os.path.join(options['data_root'], 'css')]}), - ('%s/%s/(.*)([^/]*)' % (options['web_root'], 'js'), MultiStaticFileHandler, + (r'%s/%s/(.*)(/?)' % (options['web_root'], 'js'), MultiStaticFileHandler, {'paths': [os.path.join(options['data_root'], 'js')]}) ]) @@ -131,7 +135,7 @@ def initWebServer(options={}): if enable_https: protocol = "https" server = HTTPServer(app, no_keep_alive=True, - ssl_options={"certfile": https_cert, "keyfile": https_key}) + ssl_options={"certfile": https_cert, "keyfile": https_key}) else: protocol = "http" server = HTTPServer(app, no_keep_alive=True) @@ -144,6 +148,7 @@ def initWebServer(options={}): except: pass + def shutdown(): global server