ESPMegaPRO-v3-SDK/ESPMegaPRO-firmware/lib/ESPMegaPRO/ESPMegaWebServer.cpp

25 lines
712 B
C++
Raw Normal View History

2024-01-01 06:28:15 +00:00
#include <ESPMegaWebServer.hpp>
ESPMegaWebServer::ESPMegaWebServer(uint16_t port, ESPMegaIoT *iot) {
this->port = port;
this->iot = iot;
this->server = new AsyncWebServer(port);
}
ESPMegaWebServer::~ESPMegaWebServer() {
delete this->server;
}
void ESPMegaWebServer::begin() {
this->server->begin();
auto bindedDashboardHandler = std::bind(&ESPMegaWebServer::dashboardHandler, this, std::placeholders::_1);
this->server->on("/", HTTP_GET, bindedDashboardHandler);
}
void ESPMegaWebServer::loop() {
// AsyncWebServer doesn't have a loop function
}
void ESPMegaWebServer::dashboardHandler(AsyncWebServerRequest *request) {
request->send(200, "text/plain", "Hello World!");
}