mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Only serve explicit routes
This commit is contained in:
@@ -99,9 +99,14 @@ class LoaderPageRequestHandler(SimpleHTTPRequestHandler):
|
|||||||
with open("/opt/tljh/installer.log", "rb") as log_file:
|
with open("/opt/tljh/installer.log", "rb") as log_file:
|
||||||
content = log_file.read()
|
content = log_file.read()
|
||||||
self.wfile.write(content)
|
self.wfile.write(content)
|
||||||
else:
|
elif self.path == "/index.html" or self.path == "/favicon.ico":
|
||||||
self.path = '/index.html'
|
|
||||||
return SimpleHTTPRequestHandler.do_GET(self)
|
return SimpleHTTPRequestHandler.do_GET(self)
|
||||||
|
elif self.path == "/":
|
||||||
|
self.send_response(301)
|
||||||
|
self.send_header('Location','/index.html')
|
||||||
|
self.end_headers()
|
||||||
|
else:
|
||||||
|
SimpleHTTPRequestHandler.send_error(self, code=403)
|
||||||
|
|
||||||
def serve_forever(server):
|
def serve_forever(server):
|
||||||
try:
|
try:
|
||||||
@@ -111,8 +116,11 @@ def serve_forever(server):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Serve the loading page until TLJH builds
|
# Serve the loading page until TLJH builds
|
||||||
url="https://raw.githubusercontent.com/jupyterhub/the-littlest-jupyterhub/master/bootstrap/index.html"
|
index_url="https://raw.githubusercontent.com/GeorgianaElena/the-littlest-jupyterhub/in-progress-page/bootstrap/index.html"
|
||||||
urllib.request.urlretrieve(url, "index.html")
|
favicon_url="https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/share/jupyterhub/static/favicon.ico"
|
||||||
|
urllib.request.urlretrieve(index_url, "index.html")
|
||||||
|
urllib.request.urlretrieve(favicon_url, "favicon.ico")
|
||||||
|
|
||||||
|
|
||||||
# If the bootstrap is run to upgrade TLJH, then this will raise an "Address already in use" error
|
# If the bootstrap is run to upgrade TLJH, then this will raise an "Address already in use" error
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -509,6 +509,7 @@ def main():
|
|||||||
# Remove the pid file and the temporary html page
|
# Remove the pid file and the temporary html page
|
||||||
os.remove('/loading.pid')
|
os.remove('/loading.pid')
|
||||||
os.remove('/index.html')
|
os.remove('/index.html')
|
||||||
|
os.remove('/favicon.ico')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user