compression added

This commit is contained in:
2026-09-09 01:42:52 +03:00
parent 02435cb5a6
commit b184ea76f4
4 changed files with 234 additions and 19 deletions
+10 -3
View File
@@ -27,9 +27,16 @@ PORT = CONFIG.get("port", 3232)
CLIENTS = CONFIG.get("clients", {})
# Absolute, resolved base directories for each client key, computed once at
# startup. Every request is checked against these to make sure the final
# path can never land outside the intended client folder.
CLIENT_BASE_DIRS = {key: os.path.realpath(folder) for key, folder in CLIENTS.items()}
# startup. Relative folder paths in config.json are resolved relative to
# this script's own location, not the process's current working directory,
# so `python server.py` works the same regardless of where it's launched
# from. Every request is checked against these to make sure the final path
# can never land outside the intended client folder.
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
CLIENT_BASE_DIRS = {
key: os.path.realpath(os.path.join(SCRIPT_DIR, folder))
for key, folder in CLIENTS.items()
}
# A path that is guaranteed not to exist, used to force a 404 through the
# normal http.server flow instead of ever falling back to serving files