Difference: AWEBServer (6 vs. 7)

Revision 72022-10-03 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="Exercises"

A WEB Server and the HTTP Protocol

Exercise 1: Write a Hello World WEB Server

Line: 14 to 14
 The page seen by the browser will look similar to this:

helloWorldWebServerV1.png

Changed:
<
<

Exercise 2: Provide Measurement Data on the WEB Page

>
>

Exercise 2: picoweb

Download picoweb and its example programms from gitthub: https://github.com/pfalcon/picoweb.

You can find several tutorials on picoweb on the Internet:

You may neglect the chapters on picoweb installation because the MicroPython firmware already contains a copy of picoweb:

picowebInstallation.png

For more information on the use of picoweb you will have to study the examples distributed with the github repository or picoweb itself. The examples demonstrate most of picoweb's features.

Re-write the example from exercise 1 using the picoweb framework. Now the HTML page is separated from the code and must be stored in a separate file. Upload this file to the ESP32 into a folder named html. Create the folder if it does not exist yet. You may also compress the HTML file with gzip and transfer the compressed file to the browser thus limiting the size of the message that must be sent.

Exercise 3: Provide Measurement Data on the WEB Page

  Modify the WEB server to provide temperature and humidity measured with the SHT30. The easiest way to accomplish this is static text like in the Hello World HTML page into which the measurements can be inserted. This can be done with utemplates, which are provided by picoweb. Have a look in the utemplates README.MD and in the examples directory of picoweb to understand how this is implemented.

This is how your WEB site for SHT30 measurements might look like (screen dump of the solution script):

sht30WebSite.png

Changed:
<
<

Exercise 3: Ajax

>
>

Exercise 4: Ajax

  The above exercise has a major flaw: For each measurement you must reload the entire page. It would be much nicer it the WEB page could be updated whenever a new is requested.
Line: 34 to 48
 
META FILEATTACHMENT attachment="sht30WebSite.png" attr="" comment="" date="1590609204" name="sht30WebSite.png" path="sht30WebSite.png" size="15849" user="UliRaich" version="1"
META FILEATTACHMENT attachment="http.png" attr="" comment="" date="1664785077" name="http.png" path="http.png" size="107586" user="UliRaich" version="1"
META FILEATTACHMENT attachment="helloWorldWebServerV1.png" attr="" comment="" date="1664785325" name="helloWorldWebServerV1.png" path="helloWorldWebServerV1.png" size="39692" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="picowebInstallation.png" attr="" comment="" date="1664791079" name="picowebInstallation.png" path="picowebInstallation.png" size="13656" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback