You could use HTTP directly with the espidf module. It’s more efficient because everything is implemented in C (with a Micropython API).
While only HTTP client is currently supported, I believe it should be pretty easy to add HTTP server.
HTTP/2 is also supported (but not documented yet).
Another option is to avoid communicating with the web client directly.
Instead, the device could interact with some service on a remote server with TCP socket (or UDP or any other way), and the service would push the data to the web client.
i need to figure out where that APi is and how it works.
Nah … that requires some seperate service which noone will maintain and in a few months the devices stop working.
Although Websocket and similar might be a little heavy for my simple mpy webserver as this requires ssl/md5 and such. I think using the builtin web server may the way to go.
We are using the binding script to generate Micropython API for the lodepng library which provides encoding/decoding functions for PNG.
Currently I removed the encoding part to save some program RAM since we are mostly decoding PNG files, but it’s very easy to add it back if we ever want to.
The question is what further path the image takes. If you want it to become a PNG you likely want to export it from the target device. And there are two main paths: SD card and web browser.
If you download to SD card, then yes, a easy to use image format may be useful if you don’t want to run conversion tools on the PC. But maybe it’s easier to use a potential uncompressed format like tga.
I tried something similar. After reading the first line with the GET request I simply stopped reading/parsing further header fields and just served the page immediately. Interestingly the browsers don’t like that. If you close the connection after sending the reply and before they had a chance to send all their data they complain.