Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1
FIGURE 22.1 The default Apache web server page for the Raspberry Pi.

Now that the web server is running, you can try making a test webpage of your own, which is what
we’ll cover next.


Serving HTML Files


The core function of the Apache web server is to serve HTML documents to clients on the network.
By default, the Raspberry Pi Apache web server is configured to only serve files in the /var/www
folder on the system, so you must place your web documents under that folder structure.


However, that folder is owned by the root user account. To be able to save files in that folder, you
must use the sudo command when you copy them. The following Try It Yourself shows how to
publish a simple webpage to test things out.


Try It Yourself: Publishing a Webpage
You can create a webpage document in your home folder, and then when you’re ready
to publish it, you simply copy it over to the proper folder. Just follow these steps:


  1. Create the script2201.html file in this hour’s working folder and enter the
    code shown here:
    Click here to view code image
    <!DOCTYPE html>

    Test HTML Page


    This is a test HTML page for my server





Free download pdf