Controlling GPIOs using a web interface

You've been writing programs and running command-line tools and utilities to get things done, because you are the Raspberry Pi Zero expert! While it isn't too hard, you don't necessarily want to write and run a program each time you want to turn on a motor or light or take a sensor reading. For this recipe, we are going to see how we can control the GPIO bus from a web page, being served by a web server on your Raspberry Pi Zero.

Getting ready

For this recipe, we will continue using Python, but with a new library called Flask. Flask is a micro-framework for rendering Python programs into web pages, and it will work perfectly for creating a web-based GPIO controller. If you already have python and pip updated ...

Get Raspberry Pi Zero Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.