/********* 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:55:22
********* 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 // Asynchronous WebServer library
#include // SPIFFS library for file system
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
AsyncWebServer server(80); // Create an instance of the AsyncWebServer
void setup(void)
{
// Initialize serial communication
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();
Serial.println("Server started");
}
void loop(void)
{
// Main loop can be empty as the server handles requests asynchronously
}
/* END CODE */