Book Image

Mastering IOT

By : Colin Dow, Perry Lea
Book Image

Mastering IOT

By: Colin Dow, Perry Lea

Overview of this book

The Internet of Things (IoT) is the fastest growing technology market. Industries are embracing IoT technologies to improve operational expenses, product life, and people's well-being. We’ll begin our journey with an introduction to Raspberry Pi and quickly jump right into Python programming. We’ll learn all concepts through multiple projects, and then reinforce our learnings by creating an IoT robot car. We’ll examine modern sensor systems and focus on what their power and functionality can bring to our system. We’ll also gain insight into cloud and fog architectures, including the OpenFog standards. The Learning Path will conclude by discussing three forms of prevalent attacks and ways to improve the security of our IoT infrastructure. By the end of this Learning Path, we will have traversed the entire spectrum of technologies needed to build a successful IoT system, and will have the confidence to build, secure, and monitor our IoT infrastructure. This Learning Path includes content from the following Packt products: Internet of Things Programming Projects by Colin Dow Internet of Things for Architects by Perry Lea
Table of Contents (34 chapters)
Title Page
Copyright
About Packt
Contributors
Preface
Free Chapter
1
The IoT Story
Index

Creating a simple web page using CherryPy


To get started, let's build the most basic of programs with CherryPy. By this, I mean, of course, the ubiquitous Hello World program that we will use to say Hello Raspberry Pi!. We will work through a few examples before we build a dashboard to display weather data using a modified version of the CurrentWeather class from Chapter 13Subscribing to Web Services.

Hello Raspberry Pi!

To build the Hello Raspberry Pi! web page, do the following:

  1. Open up Thonny from Application Menu | Programming | Thonny Python IDE.
  2. Click on the New icon to create a new file.
  1. Type the following:
import cherrypy

class HelloWorld():

     @cherrypy.expose
     def index(self):
         return "Hello Raspberry Pi!"

cherrypy.quickstart(HelloWorld())

  1. Ensure that the line, cherrypy.quickstart(HelloWorld()), is inline with the import and class statements.
  2. Save the file as HelloRaspberryPi.py.
  3. Run the file by clicking on the green Run current script button.
  4. You should see the CherryPy...