void notFound(AsyncWebServerRequest *request) { digitalWrite(online, HIGH); //turn-on online LED indicator if (! request->url().endsWith(F(".TXT"))) { request->send(404); } else { if (request->url().endsWith(F(".TXT"))) { //.endsWith(F(".txt"))) // here comes some mambo-jambo to extract the filename from request->url() int fnsstart = request->url().lastIndexOf('/'); fn = request->url().substring(fnsstart); PATH = fn; accessLog(); Serial.print("File: "); Serial.println(fn); File webFile = SPIFFS.open(fn); Serial.print("File size: "); Serial.println(webFile.size()); if (!webFile) { Serial.println("File: " + fn + " failed to open"); Serial.println("\n"); } else if (webFile.size() == 0) { webFile.close(); } else { //request->send(SPIFFS, fn, String(), true); //Download file request->send(SPIFFS, fn, String(), false); //Display file webFile.close(); } fn = ""; end(); } } digitalWrite(online, LOW); //turn-off online LED indicator }