/********* 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: **Web Server**
- Source Code NOT compiled for: ESP32 DevKit V1
- Source Code created on: 2024-10-14 21:00:53
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* integrate the two codes adjusting everything with */
/* ESPAsyncWebServer and SPIFFS. */
/****** END SYSTEM REQUIREMENTS *****/
/* START CODE */
/****** DEFINITION OF LIBRARIES *****/
#include
#include
#include
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
// Create an instance of the server
AsyncWebServer server(80);
// WiFi credentials
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
void setup(void)
{
// Start Serial communication for debugging
Serial.begin(115200);
// Initialize SPIFFS
if (!SPIFFS.begin(true)) {
Serial.println("SPIFFS Mount Failed");
return;
}
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Serve the index.html file from SPIFFS
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/index.htm", "text/html");
});
// Handle 404 Not Found
server.onNotFound([](AsyncWebServerRequest *request){
request->send(404, "text/plain", "Not found");
});
// Start the server
server.begin();
}
void loop(void)
{
// Main loop does nothing, all handling is done in callbacks
}
/* END CODE */