/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: **Async Server**
- Source Code NOT compiled for: ESP32 DevKit V1
- Source Code created on: 2024-10-14 20:59:13
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* adjust baseline code to convert code using */
/* espasyncwebserver and SPIFFS. Let's consider that */
/* javascript code is already integrated in html */
/* file. */
/****** END SYSTEM REQUIREMENTS *****/
/* START CODE */
/****** DEFINITION OF LIBRARIES *****/
#include //https://github.com/dvarrel/ESPAsyncWebSrv
#include // Include the FS library for SPIFFS
#include // Include the SPIFFS library
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
AsyncWebServer server(80); // Create an instance of the server
void setup(void)
{
// Initialize Serial for debugging
Serial.begin(115200);
// Initialize SPIFFS
if (!SPIFFS.begin(true)) {
Serial.println("SPIFFS Mount Failed");
return;
}
// Serve static files from SPIFFS
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm");
// Handle not found requests
server.onNotFound([](AsyncWebServerRequest *request){
request->send(404, "text/plain", "Not found");
});
// Start the server
server.begin();
}
void loop(void)
{
// Main code to run repeatedly
}
/* END CODE */