index.html is now served from SPIFFS. You can add rfid tag -> folder mappings via the webinterface. And I've added the missing controller json data messages.

This commit is contained in:
2019-11-17 00:35:23 +01:00
parent b9a4770ff2
commit 5c15a7d4cb
6 changed files with 95 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
#include "http_server.h"
#include <ESPmDNS.h>
#include <SPIFFS.h>
HTTPServer::HTTPServer(Player* p, Controller* c) {
_player = p;
@@ -8,7 +9,7 @@ HTTPServer::HTTPServer(Player* p, Controller* c) {
ws = new AsyncWebSocket("/ws");
_server->addHandler(ws);
ws->onEvent([&](AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){this->_onEvent(server, client, type, arg, data, len);});
_server->on("/", [&](AsyncWebServerRequest* req) {_handle_index(req);});
_server->on("/", [&](AsyncWebServerRequest* req) {req->send(SPIFFS, "/index.html", "text/html");});
_server->begin();
MDNS.addService("http", "tcp", 80);
}
@@ -101,11 +102,4 @@ void HTTPServer::_onEvent(AsyncWebSocket * server, AsyncWebSocketClient * client
_controller->queue_command((char*)data);
}
}
}
void HTTPServer::_handle_index(AsyncWebServerRequest* r) {
#include "index.html"
r->send(200, "text/html", html);
}