Sending client a web page stored in spiffs

I have a first homepage index.html which serves me to verify the login and the password that I transmit by post and check. So far so good, but if the passwords and login are good I cannot send back to the client the new web page stored in spiffs, for example, "accept.html" stored in Spiffs,
Thank you for your response.

void handleLogin() {    
Serial.println (" Ok");
Serial.print ("Server argument username :");
Serial.println (server.arg("username"));
Serial.print ("Server argument password :");
Serial.println (server.arg("password"));

  if( ! server.hasArg("username") || ! server.hasArg("password") 
      || server.arg("username") == NULL || server.arg("password") == NULL)
    server.send(400, "text/plain", "400: Invalid Request");         

  if(server.arg("username") == "XXXX" && server.arg("password") == "YYYY") { 
    Serial.println("Useername and password OK");

 // here is my question 
// I want to send "accepte.html" stored in SPIFFS to the client but i don't find the correct syntax
  else {    
    server.send(401, "text/plain", "401: Unauthorized");

SPIFFS is SPI Flash File System, just like any old file system on a computer. You will need to open and read the html file into a string, in your case accepte.html. Then print it out to your client using Server.send();

I'm using a handler like this

void handleInternalCss() {
  String pathWithExtension = "/i.css";
  if (SPIFFS.exists(pathWithExtension)) {
    Serial.println(F("D43 stylsheet found on SPIFFS"));
    File file =, "r");
    size_t sent = server.streamFile(file, "text/css");
    Serial.println(F("D49 stylsheet not found on SPIFFS"));

take care of the MIME type if you want to send html instead of a css.

don't read it to a String buffer ... just stream it to the server

Thanks a lot,

I used the solution of noiasca and it works perfectly.

I also tried with

    String myFile = "/accepte.html";

  if (SPIFFS.exists(myFile)) {
    Serial.println(F("myFile founded on   SPIFFS"));   //ok

   File file =, "r");                    //ok          
 server.send(200, "text/html", file);                     // pb but i don't really understand why, I think i send a file and not a text

Thanks again