April 2017
Beginner to intermediate
312 pages
7h 23m
English
Let's try turning on/off appliances at home using the Flask framework. In previous chapters, we made use of PowerSwitch Tail II to control a table lamp using the Raspberry Pi Zero. Let's try to control the same using the Flask framework. Connect PowerSwitch Tail, as shown in the following figure:

According to the Flask framework documentation, it is possible to route a URL to a specific function. For example, it is possible to bind /lamp/<control> using route() to the control() function:
@app.route("/lamp/<control>") def control(control): ...Read now
Unlock full access