From 2703689e4edd167289d358a73458406d980884c8 Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Sun, 16 Feb 2025 13:00:42 +0100 Subject: [PATCH] feat: update version to 1.1.0 and modify gzip compression handling for /spoolman route --- html/header.html | 2 +- platformio.ini | 2 +- scripts/gzip_files.py | 3 +++ src/website.cpp | 36 +++--------------------------------- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/html/header.html b/html/header.html index 01e7489..598a58a 100644 --- a/html/header.html +++ b/html/header.html @@ -12,7 +12,7 @@
-

FilaManv1.0.2

+

FilaManv1.0.9

Filament Management Tool

diff --git a/platformio.ini b/platformio.ini index 4b52659..7357845 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [common] -version = "1.0.9" +version = "1.1.0" [env:esp32dev] platform = espressif32 diff --git a/scripts/gzip_files.py b/scripts/gzip_files.py index 9035dc5..c863edb 100644 --- a/scripts/gzip_files.py +++ b/scripts/gzip_files.py @@ -13,6 +13,9 @@ def copy_file(input_file, output_file): shutil.copy2(input_file, output_file) def should_compress(file): + # Skip compression for spoolman.html + if file == 'spoolman.html': + return False # Komprimiere nur bestimmte Dateitypen return file.endswith(('.js', '.png', '.css', '.html')) diff --git a/src/website.cpp b/src/website.cpp index 5c36f58..7b86092 100644 --- a/src/website.cpp +++ b/src/website.cpp @@ -218,31 +218,8 @@ void setupWebserver(AsyncWebServer &server) { // Route für Spoolman Setting server.on("/spoolman", HTTP_GET, [](AsyncWebServerRequest *request){ Serial.println("Anfrage für /spoolman erhalten"); - - // Zuerst die gz-Datei laden - if (!SPIFFS.exists("/spoolman.html.gz")) { - request->send(404, "text/plain", "File not found"); - return; - } - - // Datei öffnen und in einen Puffer laden - File file = SPIFFS.open("/spoolman.html.gz", "r"); - size_t fileSize = file.size(); - uint8_t *gzippedContent = new uint8_t[fileSize]; - file.read(gzippedContent, fileSize); - file.close(); - - // Entpacken des gzippedContent in einen String - String html; - // TODO: Hier muss der gzippedContent entpackt werden - // Dies erfordert eine zusätzliche Bibliothek wie zlib - - // Ersetzungen vornehmen - String urlToReplace = spoolmanUrl; - if (urlToReplace.length() == 0) { - urlToReplace = ""; - } - html.replace("{{spoolmanUrl}}", urlToReplace); + String html = loadHtmlWithHeader("/spoolman.html"); + html.replace("{{spoolmanUrl}}", spoolmanUrl); JsonDocument doc; if (loadJsonValue("/bambu_credentials.json", doc) && doc.containsKey("bambu_ip")) { @@ -258,14 +235,7 @@ void setupWebserver(AsyncWebServer &server) { html.replace("{{bambuCode}}", bambuCode ? bambuCode : ""); } - // Komprimierte Antwort senden - AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", html.c_str()); - response->addHeader("Content-Encoding", "gzip"); - response->addHeader("Cache-Control", CACHE_CONTROL); - request->send(response); - - // Speicher freigeben - delete[] gzippedContent; + request->send(200, "text/html", html); }); // Route für das Überprüfen der Spoolman-Instanz