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