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> <form method="post"> <input type="submit" name="state" value="on" /> <input type="submit" name="state" value="off" /> </form> </body> </html>
Create an LED circuit setup like we did in Chapter...