O'Reilly logo

Programming the BeagleBone by Yogesh Chavan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A program to control an LED through a web browser

Let us write a program to turn an LED connected to BeagleBone ON and OFF via a web browser. You can replace the LED with a buzzer to control sound remotely or with a relay to control AC devices. Here the web browser needs to send web server information if it wants the LED to be ON or OFF. So, the HTTP command GET is not useful. We will use the HTTP command POST here to send information to the Flask web server. Create a new file in the templates directory. Write the following code inside and save it as led.html. This file has two buttons which use the POST method to send information state = on or state = off to the Flask application. The code for led.html is as follows:

<html> <body> <h1>LED</h1> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required