Compare commits
2 Commits
08370809e1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 42ea4d08fe | |||
| 48f0ab881d |
@@ -4,12 +4,12 @@
|
||||
#include "WebServer.h"
|
||||
|
||||
|
||||
void handlePage(char *page) {
|
||||
void handlePage(char *page, char *contentType) {
|
||||
if (LittleFS.exists(page)) {
|
||||
File file = LittleFS.open(page, "r");
|
||||
if (file) {
|
||||
String html = file.readString();
|
||||
server.send(200, "text/html", html);
|
||||
server.send(200, contentType, html);
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
extern ESP8266WebServer server;
|
||||
|
||||
void handlePage(char *page);
|
||||
void handlePage(char *page, char *contentType);
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -6,6 +6,7 @@
|
||||
#include "main.h"
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <LittleFS.h>
|
||||
#include "WebServer.h"
|
||||
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
|
||||
@@ -45,11 +46,12 @@ void setup() {
|
||||
} else {
|
||||
Serial.println("[DEBUG] LittleFS mounted");
|
||||
}
|
||||
server.on("/", []() { handlePage("/index.html"); });
|
||||
server.on("/xpressnet.html", []() { handlePage("/xpressnet.html"); });
|
||||
server.on("/mouse.html", []() { handlePage("/mouse.html"); });
|
||||
server.on("/js/script.js", []() { handlePage("/js/script.js"); });
|
||||
server.on("/css/style.css", []() { handlePage("/css/style.css"); });
|
||||
server.on("/", []() { handlePage("/index.html", "text/html"); });
|
||||
server.on("/xpressnet.html", []() { handlePage("/xpressnet.html", "text/html"); });
|
||||
server.on("/mouse.html", []() { handlePage("/mouse.html", "text/html"); });
|
||||
server.on("/js/mouse.js", []() { handlePage("/js/mouse.js", "application/javascript"); });
|
||||
server.on("/css/style.css", []() { handlePage("/css/style.css", "text/css"); });
|
||||
server.on("/img/Speed.png", []() { handlePage("/img/Speed.png", "image/png"); });
|
||||
server.begin();
|
||||
Serial.println("[DEBUG] Web server started");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user