further improvments, [this] in lambda fcn callback, compressed gz webfiles via streamFile()

This commit is contained in:
2021-06-26 09:21:34 +02:00
parent e8329f2587
commit 10b57ca516
5 changed files with 41 additions and 19 deletions
+28
View File
@@ -46,6 +46,34 @@ public:
streamFile(f, cont);
}
});
on("/comp.html", [this]() {
File f = open("/comp.html.gz");
if (!f) {
Serial.println("Failed to open file for reading");
}
else
{
Serial.println("Streaming /comp.html.gz to client");
const String cont = "text/html";
streamFile(f, cont);
}
});
onNotFound([this]() {
String message = "File Not Found\n\n";
message += "URI: ";
message += uri();
message += "\nMethod: ";
message += (method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += args();
message += "\n";
for (uint8_t i = 0; i < args(); i++) {
message += " " + argName(i) + ": " + arg(i) + "\n";
}
send(404, "text/plain", message);
});
if( this->addRootFileHandler() ){
this->begin();