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
cagiva
Posts: 22
Joined: Wed Dec 14, 2016 4:49 pm

How is the HTML generated/overridden?

Post by cagiva » Wed Oct 11, 2017 7:50 am

I'd like to customize the HTML page generated by this OpenMV mjpeg_streamer.py example, but I cannot figure out how it generates the HTML code or how to customize it (e.g. add a button to the page). Does anyone know how to do that?

https://github.com/openmv/openmv/blob/9 ... treamer.py

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

Re: How is the HTML generated/overridden?

Post by deshipu » Wed Oct 11, 2017 10:52 am

I think you will get much better answers at http://forums.openmv.io/

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

Re: How is the HTML generated/overridden?

Post by cagiva » Wed Oct 11, 2017 5:36 pm

deshipu wrote:I think you will get much better answers at http://forums.openmv.io/
I did, but unfortunately they don't know how the usocket generates the html in runtime or if it can be overridden.

http://forums.openmv.io/viewtopic.php?f=6&t=470

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

Re: How is the HTML generated/overridden?

Post by deshipu » Wed Oct 11, 2017 8:09 pm

That's because usocket doesn't generate any HTML.

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

Re: How is the HTML generated/overridden?

Post by cagiva » Wed Oct 11, 2017 8:31 pm

deshipu wrote:That's because usocket doesn't generate any HTML.
Then I guess you are on the same page like the OpenMV folks.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: How is the HTML generated/overridden?

Post by pythoncoder » Thu Oct 12, 2017 6:44 am

@cagiva The code you cited in your OP is quite straightforward and the HTML is there in plain text. Unless I'm missing something you need some help from someone who knows HTML form design; alas not in my repertoire.
Peter Hinch
Index to my micropython libraries.

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

Re: How is the HTML generated/overridden?

Post by cagiva » Thu Oct 12, 2017 7:00 am

pythoncoder wrote:the HTML is there in plain text.
Hi Peter,

What you saw in the code are just the HTTP headers. I'm looking to customize/override the HTML body; which is implicitly generated when the JPEG images are streamed. For instance, when I open the "inspect element" option of the browser to check the code sent from the server, I notice that there is an IMG tag that is not in the OpenMV code. It just appears from nowhere and I don't know how it gets generated.

I'm just trying to figure out how to add an input button to the mysterious HTML body sent to the browser.
Last edited by cagiva on Thu Oct 12, 2017 5:21 pm, edited 1 time in total.

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

Re: How is the HTML generated/overridden?

Post by deshipu » Thu Oct 12, 2017 7:56 am

The code generates a stream of images. There is no HTML in there what so ever. Your browser should be displaying those images directly, however, since the modern browsers go out of their way to complicate everything, your browser is adding some html around the stream of images to make the presentation "nicer". This is a bug in your browser, though it probably doesn't make any sense to report it, because they will call it a feature. The solution is to use a different browser that doesn't generate stupid html, compile your own version of that browser with the built-in html modified to your liking, or writing an explicit HTML file that you can open that would embed that image stream — you can start with the html you have copied from the browser. Just save it in a file, and open that.

alanbruce
Posts: 1
Joined: Fri Oct 13, 2017 7:01 am

Re: How is the HTML generated/overridden?

Post by alanbruce » Fri Oct 13, 2017 7:06 am

Can you please share the code once. Thanks

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: How is the HTML generated/overridden?

Post by pythoncoder » Fri Oct 13, 2017 7:50 am

I never knew browsers did that :o While this is interesting, the way browsers render HTML doesn't strike me as being relevant to @cagiva's problem.

Is there any reason why the MPEG streaming code can't emit HTML for the button along with the image?
Peter Hinch
Index to my micropython libraries.

Post Reply