Page 1 of 1

Serving multiple files / strings?

Posted: Sun Aug 05, 2018 6:10 pm
by Borisw37
Is there a way to return multiple files / strings, one after another.
Let's say I have a page that contains index.html, main.css, detail.css?

I'm using the AsyncTCP.h and ESPAsyncWebServer.h libraries.

So something like this...?
Or do I have to concatenate the strings 1st and send it all at once?

Code: Select all

	
	const char HTML[]  = ".... my html...";
	const char MAINCSS[] = "...main css...";
	const char DETAILCSS[] = "...detail css...";
	
	server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
		request->send(200, "text/html", HTML);
		request->send(200, "text/html", MAINCSS);
		request->send(200, "text/html", DETAILCSS);
	});
	

Re: Serving multiple files / strings?

Posted: Mon Aug 06, 2018 1:18 am
by ESP_Sprite
If you're trying to make a normal webserver, you don't. The client gets the index.html file sees that it refers to the two css files and separately requests these. You should handle requests for these files separately from the / URL.