Hello, first of all, apologize if it is not the appropriate area for this query!
I'm telling you, I'm trying to make a website to configure some things (the website is created with its html and css) it works well and it doesn't have any visualization problem in vscode.
It is the first time that I get into the ESP32 + web.... I have used the example of this website ESP32 Web Server using SPIFFS (SPI Flash File System) | Random Nerd Tutorials the only thing is that I have changed the SPIFFS by LITTLEFS.
Now comes the problem... the web does not load correctly, the images do not load, the index and css I can access by putting 192.168.0.26/styles but I don't know what happens with the images....
I tried another example of the webserver library and it loaded everything fine. What am I doing wrong?
The code that I use is the one in the example but I have removed the LED part...
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
//#include "SPIFFS.h"
#include <LITTLEFS.h>
// Replace with your network credentials
const char* ssid = "vodafoneCA8B";
const char* password = "D5C3ZGQKYRLF98";
// Set LED GPIO
const int ledPin = 2;
// Stores LED state
String ledState;
// Create AsyncWebServer object on port 80
AsyncWebServer server(80);
// Replaces placeholder with LED state value
String processor(const String& var){
Serial.println(var);
if(var == "STATE"){
if(digitalRead(ledPin)){
ledState = "ON";
}
else{
ledState = "OFF";
}
Serial.print(ledState);
return ledState;
}
return String();
}
void setup(){
// Serial port for debugging purposes
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
// Initialize SPIFFS
if(!LITTLEFS.begin(true)){
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
// Print ESP32 Local IP Address
Serial.println(WiFi.localIP());
// Route for root / web page
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(LITTLEFS, "/index.html", String(), false, processor);
Serial.println("CARGA INDEX");
});
// Route to load style.css file
server.on("/estilos.css", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(LITTLEFS, "/estilos.css", "text/css");
Serial.println("CARGA CSS");
});
/*
// Route to set GPIO to HIGH
server.on("/on", HTTP_GET, [](AsyncWebServerRequest *request){
digitalWrite(ledPin, HIGH);
request->send(LITTLEFS, "/index.html", String(), false, processor);
});
// Route to set GPIO to LOW
server.on("/off", HTTP_GET, [](AsyncWebServerRequest *request){
digitalWrite(ledPin, LOW);
request->send(LITTLEFS, "/index.html", String(), false, processor);
});
*/
// Start server
server.begin();
LITTLEFS.begin();
}
void loop(){
}
As I say, it's the first time I've used it... Thank you, greetings!