Hardware Reference
In-Depth Information
In this script you can see first that I created an endless loop that will keep running as long as the parent
security-server.rb
is running. You can then see that I created the
index.html
file and opened the two special
value
files for reading. I then have two loops that read from the special file and output to
index.html
. After this I closed off
all the files and have the system sleep for two seconds to allow the parent script to read the
index.html
file and refresh
the web page.
Running the Security Application
Now it's time to run it: how exciting! Ensure that
security-server.rb
and
reader-loop.rb
have their execute bit set
and then launch the application from the directory you created like this:
# ./security-server.rb
You then should see output similar to Figure
5-17
.
Figure 5-17.
Starting the security-server.rb application
You now will also see two files in your directory:
index.html
and
access.log
. Go to your Raspberry Pi's IP
address and you should see something like Figure
5-18
.
Figure 5-18.
The view from a web browser
You can see from Figure
5-18
that I am warm and moving because the PIR has a status of “0” and the pressure
mat has a status of “1”; the mat has a status of “1” because I am currently sitting down and not standing on the mat.
If you were to check back on WEBrick you may notice it was giving you an error that looks like this:
[2012-12-05 15:11:34] ERROR '/favicon.ico' not found