Book Image

BeagleBone Essentials

By : Rodolfo Giometti
Book Image

BeagleBone Essentials

By: Rodolfo Giometti

Overview of this book

Table of Contents (18 chapters)
BeagleBone Essentials
About the Author
About the Reviewers

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/ 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 then sends...