changed server response to return json success and error messsages
This commit is contained in:
parent
8a6d5b3338
commit
50af4b28f9
@ -330,7 +330,7 @@ void handleNotFound()
|
||||
{ // if the requested file or page doesn't exist, return a 404 not found error
|
||||
if (!handleFileRead(server.uri()))
|
||||
{ // check if the file exists in the flash memory (SPIFFS), if so, send it
|
||||
server.send(404, "text/plain", "404: File Not Found");
|
||||
server.send(404, "application/json", "{\"status\":\"failed\",\"message\":\"File not found\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,12 +725,12 @@ void handleFileUpload()
|
||||
fsUploadFile.close(); // Close the file again
|
||||
Serial.print("handleFileUpload Size: ");
|
||||
Serial.println(upload.totalSize);
|
||||
server.sendHeader("Location", "/success.html"); // Redirect the client to the success page
|
||||
server.send(303);
|
||||
// server.sendHeader("Location", "/success.html"); // Redirect the client to the success page
|
||||
server.send(201, "application/json", "{\"status\":\"success\",\"message\":\"File created successfully\"}");
|
||||
}
|
||||
else
|
||||
{
|
||||
server.send(500, "text/plain", "500: couldn't create file");
|
||||
server.send(500, "application/json", "{\"status\":\"failed\",\"message\":\"Could not create file\"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user