diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2013-08-30 22:48:46 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2013-08-30 22:48:46 +0200 |
commit | 3c42d5d76da5eda2ce6bedd954269161259b2289 (patch) | |
tree | 2f1084bf221c742963628b97077b826ec563a347 | |
parent | 0323d71d750ca69653a9934d344547a5a4222c48 (diff) |
Properly return favicon.ico if it exists.
-rwxr-xr-x | fbin.py | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -443,13 +443,17 @@ class Application(object): def static(self, environ, start_response, path): filename = path[1] - if not filename in ('style.css', 'no-thumbnail.png'): + if not filename in ('style.css', 'no-thumbnail.png', 'favicon.ico'): start_response('404 Not Found', []) return [] + filepath = os.path.join(settings.static_root, filename) + if not os.path.exists(filepath): + start_response('404 Not Found', []) + return [] mime = mimetypes.guess_type(filename, strict = False)[0] or 'application/octet-stream' start_response('200 OK', [('Content-Type', mime)]) - return open(os.path.join(settings.static_root, filename), 'rb') + return open(filepath, 'rb') def help(self, environ, start_response, path): c = Cookie.SimpleCookie(environ['HTTP_COOKIE'] if 'HTTP_COOKIE' in environ else None) @@ -586,6 +590,8 @@ class Application(object): module = path[0] if len(path) else '' if len(module) and module in 'fulshmitorcda': return getattr(self, module)(environ, start_response, path) + elif path == ['favicon.ico']: + return self.static(environ, start_response, ['s'] + path) else: start_response('302 Found', [('Location', settings.virtual_root + 'u')]) return [] |