Managing an LED in Python
Now let's try to manage our LED using a Python script. There are several possibilities to get a running web server with Python, but the easiest one is definitely the BaseHTTPServer
library.
You can refer to a simple usage of the library in the chapter_04/webled/python/httpd_show_info.py
demo script in the book's example code repository, where we will show you how the server handler processes the incoming requests by showing all the fields available at the disposal of the programmer.
The first part displays the definition of the server listening address, while the second part defines the GET requests handler, that is, the function to be called each time the browser performs an HTTP GET request.
The third and fourth parts are the most important ones since they implement the web data parsing. Here, we can see how the web requests are managed, and how we can use them to do our job. The fourth part simply takes the answering message built by the third part and...