From 8c289baf33a594506f439d0b05ae659162c70393 Mon Sep 17 00:00:00 2001 From: Spacehuhn Date: Sat, 23 Jan 2021 12:36:46 +0100 Subject: [PATCH] Fixed issue with LittleFS (webSpiffs) setup --- esp8266_deauther/esp8266_deauther.ino | 3 --- esp8266_deauther/wifi.cpp | 13 ++++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/esp8266_deauther/esp8266_deauther.ino b/esp8266_deauther/esp8266_deauther.ino index a47d925..e3bbad3 100644 --- a/esp8266_deauther/esp8266_deauther.ino +++ b/esp8266_deauther/esp8266_deauther.ino @@ -117,9 +117,6 @@ void setup() { displayUI.mode = DISPLAY_MODE::INTRO; } - // copy web files to SPIFFS - // copyWebFiles(false); - // load everything else names.load(); ssids.load(); diff --git a/esp8266_deauther/wifi.cpp b/esp8266_deauther/wifi.cpp index f6957b7..e1a5d11 100644 --- a/esp8266_deauther/wifi.cpp +++ b/esp8266_deauther/wifi.cpp @@ -196,6 +196,11 @@ namespace wifi { setHidden(settings::getAccessPointSettings().hidden); setCaptivePortal(settings::getWebSettings().captive_portal); + // copy web files to SPIFFS + if (settings::getWebSettings().use_spiffs) { + copyWebFiles(false); + } + // Set mode mode = wifi_mode_t::off; WiFi.mode(WIFI_OFF); @@ -404,6 +409,11 @@ namespace wifi { // ================================================================ #endif /* ifdef USE_PROGMEM_WEB_FILES */ + // aggressively caching static assets + if (settings::getWebSettings().use_spiffs) { + server.serveStatic("/", LittleFS, String(ap_settings.path).c_str(), "max-age=86400"); + } + server.on("/run", HTTP_GET, []() { server.send(200, str(W_TXT), str(W_OK).c_str()); String input = server.arg("cmd"); @@ -414,9 +424,6 @@ namespace wifi { server.send(200, str(W_JSON), attack.getStatusJSON()); }); - // aggressively caching static assets - server.serveStatic("/js", LittleFS, String(String(ap_settings.path) + "/js").c_str(), "max-age=86400"); - // called when the url is not defined here // use it to load content from SPIFFS server.onNotFound([]() {