2023-01-07 16:35:07 +01:00
|
|
|
|
#include <FS.h>
|
|
|
|
|
|
#include <SPIFFS.h>
|
|
|
|
|
|
#include <WiFi.h>
|
|
|
|
|
|
#include <WebServer.h>
|
|
|
|
|
|
|
2023-01-09 22:27:52 +01:00
|
|
|
|
#include "SD.h"
|
|
|
|
|
|
#include "SPI.h"
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_SD
|
|
|
|
|
|
SPIClass *spi = NULL;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-01-07 16:35:07 +01:00
|
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
|
|
|
|
|
#include "esp32/rom/rtc.h"
|
|
|
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
|
|
|
|
|
#include "esp32s2/rom/rtc.h"
|
|
|
|
|
|
#elif CONFIG_IDF_TARGET_ESP32C3
|
|
|
|
|
|
#include "esp32c3/rom/rtc.h"
|
|
|
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
|
|
|
|
|
#include "esp32s3/rom/rtc.h"
|
|
|
|
|
|
#else
|
|
|
|
|
|
#error Target CONFIG_IDF_TARGET is not supported
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
WebServer server(80);
|
|
|
|
|
|
|
|
|
|
|
|
void console_dbg(String msg) {
|
|
|
|
|
|
Serial.print("[Webserver] ");
|
|
|
|
|
|
Serial.println(msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool exists(String path){
|
|
|
|
|
|
bool yes = false;
|
|
|
|
|
|
File file = SPIFFS.open(path, "r");
|
|
|
|
|
|
if(!file.isDirectory()){
|
|
|
|
|
|
yes = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
file.close();
|
|
|
|
|
|
return yes;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String console_get_content_type(String filename) {
|
|
|
|
|
|
if (server.hasArg("download")) {
|
|
|
|
|
|
return "application/octet-stream";
|
|
|
|
|
|
} else if (filename.endsWith(".htm")) {
|
|
|
|
|
|
return "text/html";
|
|
|
|
|
|
} else if (filename.endsWith(".html")) {
|
|
|
|
|
|
return "text/html";
|
|
|
|
|
|
} else if (filename.endsWith(".css")) {
|
|
|
|
|
|
return "text/css";
|
|
|
|
|
|
} else if (filename.endsWith(".js")) {
|
|
|
|
|
|
return "application/javascript";
|
|
|
|
|
|
} else if (filename.endsWith(".png")) {
|
|
|
|
|
|
return "image/png";
|
|
|
|
|
|
} else if (filename.endsWith(".gif")) {
|
|
|
|
|
|
return "image/gif";
|
|
|
|
|
|
} else if (filename.endsWith(".jpg")) {
|
|
|
|
|
|
return "image/jpeg";
|
|
|
|
|
|
} else if (filename.endsWith(".ico")) {
|
|
|
|
|
|
return "image/x-icon";
|
|
|
|
|
|
} else if (filename.endsWith(".xml")) {
|
|
|
|
|
|
return "text/xml";
|
|
|
|
|
|