#include "WebServer.hpp" #include "../SdCard.hpp" #include "esp_log.h" #include static const char* TAG = "WebServer"; esp_err_t WebServer::rootHandler(httpd_req_t* req) { if (!SdCard::instance().isMounted()) { httpd_resp_set_type(req, "text/html; charset=utf-8"); const char* errorPage = "

SD Card Error

" "

SD card not mounted. Please insert SD card with /webseite/index.html

" "

Open File Manager

"; httpd_resp_send(req, errorPage, strlen(errorPage)); return ESP_OK; } return sendFile(req, "/sdcard/webseite/index.html"); } esp_err_t WebServer::staticFileHandler(httpd_req_t* req) { char filepath[CONFIG_HTTPD_MAX_URI_LEN + 8]; snprintf(filepath, sizeof(filepath), "/sdcard%.*s", (int)(sizeof(filepath) - 8), req->uri); return sendFile(req, filepath); } esp_err_t WebServer::imagesHandler(httpd_req_t* req) { char filepath[CONFIG_HTTPD_MAX_URI_LEN + 8]; snprintf(filepath, sizeof(filepath), "/sdcard%.*s", (int)(sizeof(filepath) - 8), req->uri); return sendFile(req, filepath); }