Page 1 of 1

ESP32 - PlatformIO - Server Erro HTML

Posted: Thu Jun 15, 2023 9:08 pm
by MicheliBarcello
Good Afternoon Guys, How are you?
I have an error when I try to run my programming, I saw several tutorials and they all work, but mine is not working, could someone help me to identify the problem?

Follow my .cpp programming

Code: Select all

#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <FS.h>
#include <SPIFFS.h>

AsyncWebServer server(80);

const char* ssid = "Michelii";
const char* password = "Barcello";

void conectarWiFi() {
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Conectando ao Wi-Fi...");
  }
  Serial.print("Endereço IP: ");
  Serial.println(WiFi.localIP());
  Serial.println("Conexão Wi-Fi estabelecida");
}

void setup() {

  Serial.begin(115200);
  conectarWiFi();

  if(!SPIFFS.begin(true)){
    Serial.println("Ocorreu um erro ao montar SPIFFS");
    return;
  }

  server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(SPIFFS, "/index.html");

  });

  server.begin();
}

void loop() {
  delay(1000);
  Serial.println("Teste");
}
Here's a photo of the error

Code: Select all

<html>
<head>
  <meta charset='utf-8'/>
</head>
<body>
  <h1>
    ESP32
  </h1>          
  <p>
    Hello my friends!
  </p>          
</body>
<html>
Here's a photo of the error
Image

Image

Image

Re: ESP32 - PlatformIO - Server Erro HTML

Posted: Wed Jun 21, 2023 4:37 pm
by username
did you upload the files in the data folder using the following commands ?

#1) pio run --target erase
#2) pio run -t uploadfs

number 2 will upload the files in the data folder. Then re-flash the board and try it.