Cleanup setup

This commit is contained in:
Gabriel Augendre 2023-01-01 03:02:57 +01:00
parent b67b057d48
commit 418499aff8

View file

@ -80,13 +80,12 @@ void setup()
// List existing files // List existing files
File root = SPIFFS.open("/music"); File root = SPIFFS.open("/music");
File file = root.openNextFile(); File file = root.openNextFile();
while (file) if (file)
{ {
String fileName = file.name(); String fileName = file.name();
if (selectedFile == "" && !fileName.startsWith(".")) if (!fileName.startsWith("."))
selectedFile = fileName; selectedFile = fileName;
file.close(); file.close();
file = root.openNextFile();
} }
// Wifi // Wifi
@ -113,6 +112,7 @@ void setup()
server.on("/select-file", HTTP_POST, onSelectFile); server.on("/select-file", HTTP_POST, onSelectFile);
server.serveStatic("/", SPIFFS, "/www/").setDefaultFile("index.html"); server.serveStatic("/", SPIFFS, "/www/").setDefaultFile("index.html");
server.begin(); server.begin();
Serial.println("Server ready!"); Serial.println("Server ready!");
} }