WebServer: fixed 404 handling and listanim

This commit is contained in:
Thomas Kolb 2019-12-14 23:54:42 +01:00
parent 1410124e49
commit af3adf99db

View file

@ -21,6 +21,11 @@ WebServer::WebServer(void)
bool WebServer::serveFile(String filename, httpsserver::HTTPResponse *res) bool WebServer::serveFile(String filename, httpsserver::HTTPResponse *res)
{ {
uint8_t buf[1024]; uint8_t buf[1024];
if(!SPIFFS.exists(filename)) {
return false;
}
File f = SPIFFS.open(filename.c_str(), "r"); File f = SPIFFS.open(filename.c_str(), "r");
if(!f) { if(!f) {
@ -149,9 +154,11 @@ void WebServer::handleListAnim(httpsserver::HTTPRequest *req, httpsserver::HTTPR
res->print("["); res->print("[");
for(size_t i = 0; i < AnimationController::AnimationNames.size(); i++) { for(size_t i = 0; i < AnimationController::AnimationNames.size(); i++) {
res->print("{\"id\": "); res->print("{\"id\":");
res->print(i); res->print(i);
res->print("}"); res->print(",\"name\":\"");
res->print(AnimationController::AnimationNames[i]);
res->print("\"}");
if(i < AnimationController::AnimationNames.size()-1) { if(i < AnimationController::AnimationNames.size()-1) {
res->print(","); res->print(",");