This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server.on("/debug", HTTP_GET, dirList); | |
// server.on("/debug", HTTP_PUT, dirList); | |
// server.on("/debug", HTTP_POST, dirList); | |
void handleDebug() { | |
String message = "HTTP Request\n\n"; | |
message += "URI: "; | |
message += server.uri(); | |
message += "\nMethod: "; | |
message += (server.method() == HTTP_GET) ? "GET" : "POST"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server.on("/dir", HTTP_GET, handleDirList); | |
void handleDirList() { | |
SPIFFS.begin(); | |
String str = ""; | |
Dir dir = SPIFFS.openDir("/"); | |
while (dir.next()) { | |
str += dir.fileName(); | |
str += " "; | |
str += dir.fileSize(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this serves all URLs that can be resolved to a file on the SPIFFS filesystem | |
// server.onNotFound(handleNotFound); | |
static String getContentType(const String& path) { | |
if (path.endsWith(".html")) return "text/html"; | |
else if (path.endsWith(".htm")) return "text/html"; | |
else if (path.endsWith(".css")) return "text/css"; | |
else if (path.endsWith(".txt")) return "text/plain"; | |
else if (path.endsWith(".js")) return "application/javascript"; | |
else if (path.endsWith(".png")) return "image/png"; |
NewerOlder