From af3adf99dba5f2fe73cf2d2cff3b398dfd960be1 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sat, 14 Dec 2019 23:54:42 +0100 Subject: [PATCH] WebServer: fixed 404 handling and listanim --- src/WebServer.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/WebServer.cpp b/src/WebServer.cpp index 0d1e409..a0443ca 100644 --- a/src/WebServer.cpp +++ b/src/WebServer.cpp @@ -21,6 +21,11 @@ WebServer::WebServer(void) bool WebServer::serveFile(String filename, httpsserver::HTTPResponse *res) { uint8_t buf[1024]; + + if(!SPIFFS.exists(filename)) { + return false; + } + File f = SPIFFS.open(filename.c_str(), "r"); if(!f) { @@ -149,9 +154,11 @@ void WebServer::handleListAnim(httpsserver::HTTPRequest *req, httpsserver::HTTPR res->print("["); for(size_t i = 0; i < AnimationController::AnimationNames.size(); i++) { - res->print("{\"id\": "); + res->print("{\"id\":"); res->print(i); - res->print("}"); + res->print(",\"name\":\""); + res->print(AnimationController::AnimationNames[i]); + res->print("\"}"); if(i < AnimationController::AnimationNames.size()-1) { res->print(",");