further improvments, [this] in lambda fcn callback, compressed gz webfiles via streamFile()
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user