I have an app using ESPASynchWebServer that is working just great. But now I want to add something, and don't know how to do it. At present, all web requests are satisfied by either returning a file, or a fairly short String response. But now I would like to respond with a large block of String data that is created on-the-fly, but I want to create and send the response in chunks, perhaps or, or a few, lines at a time, rather than having to build then send a single long String response.
Is there a way to do this? Is there an example somewhere I've missed?
I've just discovered the template capability, which might be a solution. Is it possible to have a file that provides the of the HTML, with embedded template data? I've only fund one template example so far, and it has the HTML in an in-memory String. If I can instead use a SPIFFS file to hold the HTML, and still use the template data, I think that would work for me.
Is that possible?
It sounds reasonable. If the main web page file is sent first, then the browser client should request the data links contained in the page.
But now I would like to respond with a large block of String data that is created on-the-fly, but I want to create and send the response in chunks, perhaps or, or a few, lines at a time, rather than having to build then send a single long String response.
but why ? what is wrong with sending a 'String' response ? The EspWebserver only has the .send() function as far as i know (the Async version doesn't wait for the .handleClient() to be called i think that is the only difference) Are you worried you are going to run out of memory :o
The file send() method I'm already using has two optional parameters, one of which is a template handler callback. It works just great, and is close enough to what I need that I will use it. So, most of the HTML now comes from a SPIFFS file, with the template handler filling in the "dynamic" values on-the-fly.