You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
840 B
C++
37 lines
840 B
C++
4 years ago
|
#include "app.h"
|
||
4 years ago
|
#include "SPIFFS.h"
|
||
|
#include "ESPAsyncWebServer.h"
|
||
|
|
||
|
// https://techtutorialsx.com/2018/09/17/esp32-arduino-web-server-serving-external-css-file/
|
||
|
// https://docs.platformio.org/en/latest/platforms/espressif8266.html#uploading-files-to-file-system-spiffs
|
||
|
|
||
|
AsyncWebServer server(80);
|
||
|
|
||
4 years ago
|
|
||
4 years ago
|
void setupApp()
|
||
4 years ago
|
{
|
||
4 years ago
|
Serial.println("setup configure");
|
||
|
|
||
|
if (!SPIFFS.begin()) {
|
||
|
Serial.println("An Error has occurred while mounting SPIFFS");
|
||
|
return;
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
|
|
||
4 years ago
|
// @see https://github.com/me-no-dev/ESPAsyncWebServer
|
||
|
|
||
|
// DirectoryIndex Directive
|
||
|
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
||
|
request->send(SPIFFS, "/dist/index.html", "text/html");
|
||
4 years ago
|
});
|
||
|
|
||
4 years ago
|
// serve static files
|
||
|
server
|
||
|
.serveStatic("/", SPIFFS, "/dist/")
|
||
|
.setCacheControl("max-age=600")
|
||
|
;
|
||
|
|
||
4 years ago
|
server.begin();
|
||
|
|
||
|
Serial.println("setup configure - done");
|
||
4 years ago
|
}
|