2

I can load spiff docs, but I get a 404. Wireless works, IP addressing works and I can load other examples successfully. This simple image load ino is giving me fits!

#include <WiFi.h>#include <AsyncTCP.h>#include <SPIFFS.h>#include <ESPAsyncWebServer.h>const char *ssid = "x";const char *password =  "123456789";IPAddress staticIP(10,0,0,1); //ESP static ipIPAddress gateway(0,0,0,0);   //IP Address of your WiFi Router (Gateway)IPAddress subnet(255, 255, 255, 0);  //Subnet maskAsyncWebServer server(80);void setup() {  Serial.begin(115200);  WiFi.softAP(ssid, password);server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){request->send(SPIFFS, "/index.htm", "text/html");});     server.on("/image.png", HTTP_GET, [](AsyncWebServerRequest *request){request->send(SPIFFS, "/image.png", "image/png");});server.begin();}//END setupvoid loop() {}
<!DOCTYPE HTML><html><head>     <meta charset='UTF-8'></head><body>     <img src="image.png" alt=" image goes here"></body></html>
timemage's user avatar
timemage
5,7391 gold badge15 silver badges27 bronze badges
askedNov 15, 2020 at 8:21
Marr Madden's user avatar

1 Answer1

0

I don't have an ESP32 to test with. Though, I tried to make your code run on an ESP8266, but it's a bit of an effort to validate what is ultimately a wild guess on my part.

And that is:perhaps you have some uppercase letters in your filename such that"/image.png" does not match perfectly and furthermoremaybe SPIFFS is case sensitive. That is, your file could be named Image.png or IMAGE.png and that might matter.

UPDATE:

In my exploring this on the ESP8266, I'd forgotten to executeSPIFFS.begin(). And I see no counterpart to it in your code.At least one example of ESPAsyncWebServer I've seendoes callSPIFFS.begin()

I found that the filenamesare case sensitive, again at least on the ESP8266; so that can be a source of problems.

Also checked that if the SPIFFS size is changed through menu selections, I did indeed need to reupload the SPIFFS image.

I know these are different systems; in fact the code I'm using to test doesn't compile for ESP32, but I suspect a lot of the code is shared, and so maybe the problems are as well.

answeredNov 15, 2020 at 20:58
timemage's user avatar
1
  • 1
    This is it! Thanks for taking the time.CommentedNov 16, 2020 at 2:49

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.