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 4, Subscribing to Web Services.
Creating a simple web page using CherryPy
Hello Raspberry Pi!
To build the Hello Raspberry Pi! web page, do the following:
- Open up Thonny from Application Menu | Programming | Thonny Python IDE.
- Click on the New icon to create a new file.
- Type the following:
import cherrypy
class HelloWorld():
@cherrypy.expose
def index(self):
return "...