diff --git a/.env.defaults b/.env.defaults index 661e585..ea98216 100644 --- a/.env.defaults +++ b/.env.defaults @@ -1,4 +1,4 @@ PORT = 8000 GRAB_SYMLINKS = true -SYMLINKS_DIR = "symlinks" +SYMLINK_DIR = "symlinks" STATIC_SHARE_RESTRICTION = true \ No newline at end of file diff --git a/serve.py b/serve.py index 83f50fe..8ddf373 100644 --- a/serve.py +++ b/serve.py @@ -56,6 +56,8 @@ class CustomHandler(http.server.SimpleHTTPRequestHandler): project_id = parts[0] project_dir = get_project_directory(project_id) + if not project_dir: + return os.path.join(BASE_DIR, "404.html") # Check .staticshare restriction if STATIC_SHARE_RESTRICTION: staticshare_path = os.path.join(project_dir, ".staticshare") @@ -88,6 +90,14 @@ class CustomHandler(http.server.SimpleHTTPRequestHandler): project_dir = get_project_directory(project_id) + if not project_dir: + self.send_response(404) + self.send_header("Content-type", "text/html") + self.end_headers() + with open(os.path.join(BASE_DIR, "404.html"), "rb") as f: + self.wfile.write(f.read()) + return + if STATIC_SHARE_RESTRICTION: staticshare_path = os.path.join(project_dir, ".staticshare") if not os.path.isfile(staticshare_path):