ugly hack
This commit is contained in:
@@ -12,4 +12,5 @@ void writeFile(const char * path, const char * message);
|
||||
void appendFile(const char * path, const char * message);
|
||||
void renameFile(const char * path1, const char * path2);
|
||||
void deleteFile(const char * path);
|
||||
|
||||
#endif // __FILESYS_H
|
||||
+30
-19
@@ -1,37 +1,48 @@
|
||||
#ifndef __HTTPSERVER_H
|
||||
#define __HTTPSERVER_H
|
||||
|
||||
#include "filesys.h"
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
|
||||
class HTTPServer {
|
||||
private:
|
||||
int port;
|
||||
ESP8266WebServer* server;
|
||||
bool configured = false;
|
||||
const int port;
|
||||
const char* rootDir;
|
||||
std::function<void ()> callbackFn;
|
||||
|
||||
bool addRootFileHandler();
|
||||
bool formatFS() {
|
||||
return format_fs();
|
||||
}
|
||||
void listRoot() {
|
||||
ls(rootDir);
|
||||
}
|
||||
|
||||
public:
|
||||
HTTPServer(int port) {
|
||||
server = new ESP8266WebServer;
|
||||
ESP8266WebServer server;
|
||||
|
||||
// server->on("/", handleRootGz);
|
||||
// server->on("/style.css", handleCssGz);
|
||||
// server->on("/favicon.png", handleFaviconGz);
|
||||
// server->onNotFound(handleNotFound);
|
||||
|
||||
server->begin(port);
|
||||
}
|
||||
~HTTPServer() {
|
||||
server->stop();
|
||||
delete server;
|
||||
HTTPServer(const int _port, const char* _rootDir, std::function<void ()> fn) :
|
||||
port(_port), rootDir(_rootDir), callbackFn(fn)
|
||||
{ }
|
||||
~HTTPServer()
|
||||
{
|
||||
server.stop();
|
||||
}
|
||||
|
||||
void initialize() {
|
||||
server->begin(port);
|
||||
bool start() {
|
||||
if(!mount_fs())
|
||||
return false;
|
||||
Serial.printf("LittleFS mounted => Starting Webserver on Port %d\n\r", this->port);
|
||||
server.begin(port);
|
||||
return true;
|
||||
}
|
||||
|
||||
void handleClient() {
|
||||
server->handleClient();
|
||||
void handleClient() {
|
||||
server.handleClient();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // __HTTPSERVER_H
|
||||
Reference in New Issue
Block a user