html to variable

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
bellad
Posts: 9
Joined: Tue May 14, 2019 1:47 pm

html to variable

Post by bellad » Thu Sep 12, 2019 7:39 am

hello,
i would collect 2variable in html to micropython , but how to do ?

Code: Select all

<p align="center" style="margin-bottom: 0cm; line-height: 100%"><B>Demande exceptionnelle</B></p>
  <div>
    <p align="center" style="margin-bottom: 0cm; line-height: 100%">
    <input type="text" id="name1" name="name1" required
       minlength="2" maxlength="2" size="3">
	   <label for="Choi1"> Degrés  |  </label>
	<input type="text" id="name2" name="name2" required
       minlength="1" maxlength="2" size="2"> 
       <label for="Choi2">Heure(s) |</label>
      <p align="center" style="margin-bottom: 0cm; line-height: 100%"><input type="submit" value="Enregistrer">	   
   </div>
thank you
sorry for my english , i use google translate
Attachments
dem.jpg
dem.jpg (8.63 KiB) Viewed 61 times

ThomasChr
Posts: 120
Joined: Sat Nov 25, 2017 7:50 am

Re: html to variable

Post by ThomasChr » Fri Sep 13, 2019 9:30 am

One way would be to have the html elements in a <form> element with a submit-Tag which has the address of the pyboard in it. Whenever you submit the form the values of the variables will be submitted with it, either in the url (method=get) or in the body (method=post) of the request.

A little bit more complicated would be a Javascript xmlhttprequest. This can be totally asynchronous and the data format can be more changed by you, for example JSON.

Thomas

bellad
Posts: 9
Joined: Tue May 14, 2019 1:47 pm

Re: html to variable

Post by bellad » Fri Sep 13, 2019 12:16 pm

thank you Thomas

do you have an example?

User avatar
jimmo
Posts: 509
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: html to variable

Post by jimmo » Fri Sep 13, 2019 12:19 pm

Take a look at "microdot" which is a web server for MicroPython. It includes an example that has a web page that lets you control a GPIO pin.

https://github.com/miguelgrinberg/microdot

bellad
Posts: 9
Joined: Tue May 14, 2019 1:47 pm

Re: html to variable

Post by bellad » Fri Sep 13, 2019 12:36 pm

thank's , ok I study the example

Post Reply