---+ Installing the picoweb server The description of picoweb on its git repository explains it as follows: picoweb is a "micro" web micro-framework (thus, "pico-framework") for radically unbloated web applications using radically unbloated Python implementation, Pycopy, https://github.com/pfalcon/pycopy . As you can see, it is designed to run of pycopy, a fork of standard !MicroPython, which we use on our ESP32 micro-controller. It depends on several packages, which are normally not part of the standard !MicroPython binary such that we either install these dependencies with upip or, better, freeze them into a custom !MicroPython binary. picoweb depends on: * utemplate * uasyncio * pkg_resources * ulogging In order to make these packages available I copy them into the _modules_ directory of the esp32 !MicroPython port: <img alt="esp32Modules.png" height="73" src="%ATTACHURL%/esp32Modules.png" title="esp32Modules.png" width="777" /> utemplate can be found at https://github.com/pfalcon/utemplate uasyncio is part of [[https://github.com/micropython/micropython-lib][micropython-lib ]]but need a small modification (the awritestr method must be added): <img alt="uasyncioMod.png" height="247" src="%ATTACHURL%/uasyncioMod.png" title="uasyncioMod.png" width="682" /> _pkg_resources_ is the version found in micropython-lib _ulogging_ is <i>logging, </i>found in micropython-lib, renamed _ulogging_ As you can see, we also copied picoweb itself into the modules directory. After compiling !MicroPython all these modules will be available for use. ---++ Running the WEB server In the picoweb repository you will find a series of examples: In the picoweb directory you find _example_webapp.py_ and _example_webapp2.py_, where <i>example_webapp2.py </i>is essentially a subset of _example_webapp.py_. There is also an "<i>examples</i>" directory with mode examples. In order to make this example run you have to * create a directory called templates on the ESP32 file system and copy squares.tpl into it * create the wifi_connect file (see the connect to !WiFi description in [[https://techtutorialsx.com/2017/09/01/esp32-micropython-http-webserver-with-picoweb][https://techtutorialsx.com/2017/09/01/esp32-micropython-http-webserver-with-picoweb) ]] * modify _yourNetworkName_ and <i>yourNetworkPassword </i>to adapt the script to your !WiFi SSID and password and upload the modified script to the ESP32 * on the ESP32:<br />import wifi_connect<br />wifi_connect.connect()<br />will connect to your !WiFi network and print the IP address of the WEB server. * In example_webapp.py modify<br /><i>app = picoweb.WebApp(<b>__</b>name<b>__</b>, ROUTES)</i> to _app = picoweb.WebApp(None, ROUTES)_ * add host="xxx.xxx.xxx.xxx" to app.run where xxx.xxx.xxx.xxx must be replaced by the IP address you get from wifi_connect. In may case:<br />app.run(debug=1,host="192.168.1.49") * copy _example_webapp_.py to the ESP32 * on the ESP32:<br />import picoweb<br />will start the WEB server A few screen dumps show the procedure: -- %USERSIG{UliRaich - 2020-01-24}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
esp32Modules.png
r1
manage
23.7 K
2020-01-24 - 10:43
UliRaich
png
uasyncioMod.png
r1
manage
36.4 K
2020-01-24 - 10:50
UliRaich
This topic: AFNOG
>
WebHome
>
AFNOGWorkshop2020
>
Picoweb
Topic revision: r1 - 2020-01-24 - UliRaich
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback