Book Image

Raspberry Pi Networking Cookbook - Second Edition

By : Rick Golden
Book Image

Raspberry Pi Networking Cookbook - Second Edition

By: Rick Golden

Overview of this book

<p>With increasing interest in Maker Projects and the Internet of Things (IoT), students, scientists, and hobbyists are using the Raspberry Pi as a reliable, inexpensive platform to connect local devices to Internet services.</p> <p>This book begins with recipes that are essential to installing the Raspberry Pi and configuring it for network access. Then it continues with recipes on installing common networking services such as firewalls and file sharing.</p> <p>The final chapters include recipes for network monitoring, streaming data from the Raspberry Pi to IoT services, and using clusters of Raspberry Pis to store and analyze large volumes of data.</p>
Table of Contents (14 chapters)
Raspberry Pi Networking Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Controlling devices from a web page


This recipe uses a simple Python script to show how devices attached to the Raspberry Pi can be controlled from a web page.

The web.py programming framework for Python can be used to serve web pages from scripts that are written in the Python programming language. This recipe features a Python script that serves a web page displaying the current state of a GrovePi LED and enables a button on the web page to turn a GrovePi LED on and off. It is a simple example, but is an excellent foundation for simple Internet of Things projects.

After completing this recipe, you will have installed and applied the web.py Python framework to serve a web page that can be used to turn an LED on and off.

Getting ready

The following are the ingredients for controlling devices from a web page:

  • An initial setup or basic networking setup for the Raspberry Pi that already has the GrovePi interfaces and drivers installed (see the previous recipe, Installing the GrovePi, for instructions...