diff --git a/21_esp_html_fs/data/fotka.html b/21_esp_html_fs/data/fotka.html new file mode 100644 index 0000000..0b78aa3 --- /dev/null +++ b/21_esp_html_fs/data/fotka.html @@ -0,0 +1,18 @@ + + + + + + Document + + + + +

Fotka na druhé stránce

+ + Naše logo uložené v ESP32 + + \ No newline at end of file diff --git a/21_esp_html_fs/data/logo.png b/21_esp_html_fs/data/logo.png new file mode 100644 index 0000000..c3e4061 Binary files /dev/null and b/21_esp_html_fs/data/logo.png differ diff --git a/21_esp_html_fs/src/main.cpp b/21_esp_html_fs/src/main.cpp index e93ece4..d1f3df2 100644 --- a/21_esp_html_fs/src/main.cpp +++ b/21_esp_html_fs/src/main.cpp @@ -39,6 +39,29 @@ void handleRoot() { if (teplota > 30) teplota = 15; } +void handleFotka() { + File file = LittleFS.open("/fotka.html","r"); + if(!file) { + server.send(500,"text/plain","Chyba serveru 500"); + return; + } + server.streamFile(file,"text/html"); + file.close(); +} + +void handleLogo() { + File file = LittleFS.open("/logo.png","r"); + if(!file) { + server.send(500,"text/plain","Chyba serveru 500"); + return; + } + server.streamFile(file,"image/png"); + file.close(); +} +void handleNotFound(){ + server.send(404,"text/plain","404 - Nic nenalezeno, mňo máš smůlu ☺"); +} + void setup() { Serial.begin(115200); //Inicializaceš fylesystému LittleFS @@ -61,6 +84,9 @@ void setup() { Serial.println(WiFi.localIP()); server.on("/",handleRoot); + server.on("/fotka",handleFotka); + server.on("/logo.png",handleLogo); + server.onNotFound(handleNotFound); server.begin(); Serial.println("HTTP server běží");