Handle WebServer
This commit is contained in:
18
src/WebServer.cpp
Normal file
18
src/WebServer.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <Arduino.h>
|
||||
#include <LittleFS.h>
|
||||
#include "main.h"
|
||||
#include "WebServer.h"
|
||||
|
||||
|
||||
void handlePage(char *page) {
|
||||
if (LittleFS.exists(page)) {
|
||||
File file = LittleFS.open(page, "r");
|
||||
if (file) {
|
||||
String html = file.readString();
|
||||
server.send(200, "text/html", html);
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
server.send(404, "text/plain", "Page not found");
|
||||
}
|
||||
Reference in New Issue
Block a user