Serving multiple files / strings?

Borisw37
Posts: 2
Joined: Sun Aug 05, 2018 6:00 pm

Serving multiple files / strings?

Postby Borisw37 » Sun Aug 05, 2018 6:10 pm

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);
	});
	

ESP_Sprite
Posts: 9715
Joined: Thu Nov 26, 2015 4:08 am

Re: Serving multiple files / strings?

Postby ESP_Sprite » Mon Aug 06, 2018 1:18 am

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.

Who is online

Users browsing this forum: No registered users and 131 guests