Search code examples
arduinowebserveresp8266arduino-esp8266

Update/remove page ESP8266 Webserver


I'm using the ESP8266WebServer.h library for the ESP8266. Files can be served to a specific filename by using something like:

...

void example() {
  sendFile(200, "text/html", data_example, sizeof(data_example));
}

...

webServer.on ("/example.html", example);

Once a file is served it cannot be updated by executing server.on ("/example.html", example2);.

How can a hosted file be removed (or updated to a blank file) so that it will return a 404 error ?


Solution

  • why not include a conditionnal logic in your example() function in order serve a 404 page when necessary ?

    Hope it helps.