mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 14:03:02 +00:00

by specifying JupyterHub.logo_file also ensures single-user server always has the same logo image as the Hub
29 lines
860 B
Python
29 lines
860 B
Python
# Copyright (c) Jupyter Development Team.
|
|
# Distributed under the terms of the Modified BSD License.
|
|
|
|
import os
|
|
from tornado.web import StaticFileHandler
|
|
|
|
class CacheControlStaticFilesHandler(StaticFileHandler):
|
|
"""StaticFileHandler subclass that sets Cache-Control: no-cache without `?v=`
|
|
|
|
rather than relying on default browser cache behavior.
|
|
"""
|
|
def compute_etag(self):
|
|
return None
|
|
|
|
def set_extra_headers(self, path):
|
|
if "v" not in self.request.arguments:
|
|
self.add_header("Cache-Control", "no-cache")
|
|
|
|
class LogoHandler(StaticFileHandler):
|
|
"""A singular handler for serving the logo."""
|
|
def get(self):
|
|
return super().get('')
|
|
|
|
@classmethod
|
|
def get_absolute_path(cls, root, path):
|
|
"""We only serve one file, ignore relative path"""
|
|
return os.path.abspath(root)
|
|
|