Difference: WEBServerPicoweb (7 vs. 8)

Revision 82020-06-08 - UliRaich

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

A WEB Server on the ESP32

A "Hello World!" WEB server

Line: 18 to 18
 In the second version we will separate the HTML text from the server and store it in the html directory (to be created with ampy: ampy mkdir /html) on the ESP32. Now we can use a ready made Web server for MicroPython, picoweb to serve the page. picoweb and utemplates (see exercise 2) are already included in the MicroPython binary.

Studying example_webapp.py in the base directory of picoweb will show you how to do this.

Added:
>
>
Since from now on we will have to upload several file to the ESP32 I provide shell scripts named setup.sh which create directories like /html to store html files, /templates to store templates (see later) and /static to store static images. In fact it the script will check if the directories already exist on the ESP32 and create them only if not. Once the directories are created it stores the necessary html files, templates or images into their corresponding directory.
 
Version 3:

If we do not use an external SD card, then space for the HTML pages is rather limited. It may therefore be interesting to use gzip compresses pages. Modify your picoweb server to use gzipped HTML.

Line: 76 to 78
 Essentially you must create aXMLHttpRequest, which you send from the client to the server and to which the server will respond. You use the answer from the server to update the HTML page using javascript. The ledControl.html file defines 2 functions: ledOn() and ledOff() sending an XMLHttpRequest to the WEB server. The WEB server switches the user LED on or off and answers with the current state of the LED. This information is used be the javascript code in the html file to show a lighted or dark LED icon.

ajaxLEDServer.py in the tar archive is the WEB server to be run on the ESP32, /html/ledControl.html is the HTML and javascript file and setup.sh is a shell script uploading all the necessary files to their correct places in the ESP32 file system.

Changed:
<
<

Making Temperature and Humidity measurements available to the WEB page

>
>

Making Temperature and Humidity measurements available to the WEB page through AJAX

  With the knowledge on how to measure temperature and humidity and the knowledge on how to communicate between the WEB client and the WEB server using AJAX we have all we need to create a WEB page showing periodic temperature and humidity measurements. For measurement of other parameters we only need to implement the driver code reading out the sensor in addition.
 
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