How is the HTML generated/overridden?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: How is the HTML generated/overridden?

Post by deshipu » Fri Oct 13, 2017 12:58 pm

pythoncoder wrote:
Fri Oct 13, 2017 7:50 am
Is there any reason why the MPEG streaming code can't emit HTML for the button along with the image?
Yes, the basic principles on which HTTP was designed: one address gives you one document, in this case it's a stream of JPEG images. What you can do is serve your own HTML on one address, and have it embed a different address on which you would serve the stream of JPEG images. It would however require you to either listen on two different ports, or parse the request header to see what address was requested and act accordingly — this would complicate the code a bit.

User avatar
cagiva
Posts: 22
Joined: Wed Dec 14, 2016 4:49 pm

Re: How is the HTML generated/overridden?

Post by cagiva » Fri Oct 13, 2017 4:37 pm

@deshipu, You were absolutely correct regarding the browser. I ran a test using three(3) different browsers, and each one generated their own HTML interpretation of "Content-Type: image/jpeg". So, that mystery is resolved.
deshipu wrote: What you can do is serve your own HTML on one address, and have it embed a different address on which you would serve the stream of JPEG images.
Regarding you last post, did you mean serve my own HTML on one URL path and serve the streamed JPEG on another URL path; as shown below?

https://github.com/berak/opencv_smallfr ... g_serve.py

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: How is the HTML generated/overridden?

Post by deshipu » Fri Oct 13, 2017 5:27 pm

Yes, something like that should work.

Post Reply