From 0b04f098de6c113a9abece540f45983568057df4 Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Thu, 6 Mar 2025 02:06:53 +0300 Subject: [PATCH] preload all pages. --- app/library/HttpAPI.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/library/HttpAPI.py b/app/library/HttpAPI.py index 0687db10..be9f7059 100644 --- a/app/library/HttpAPI.py +++ b/app/library/HttpAPI.py @@ -208,14 +208,15 @@ class HttpAPI(Common): app.router.add_get(urlPath, self._static_file) preloaded += 1 - if urlPath.endswith("/index.html") and urlPath != "/index.html": - parentSlash = urlPath.replace("/index.html", "/") - parentNoSlash = urlPath.replace("/index.html", "") - self._static_holder[parentSlash] = {"content": content, "content_type": contentType} - self._static_holder[parentNoSlash] = {"content": content, "content_type": contentType} - app.router.add_get(parentSlash, self._static_file) - app.router.add_get(parentNoSlash, self._static_file) - preloaded += 2 + if urlPath.endswith("/index.html"): + paths_list = ["/console", "/presets", "/tasks", "/notifications"] + for path in paths_list: + self._static_holder[path] = {"content": content, "content_type": contentType} + app.router.add_get(path, self._static_file) + self._static_holder[path + "/"] = {"content": content, "content_type": contentType} + app.router.add_get(path + "/", self._static_file) + LOG.debug(f"Preloading '{path}'.") + preloaded += 1 if preloaded < 1: message = f"Failed to find any static files in '{staticDir}'."