#!/usr/bin/env python3 #Based off the tutorial by adafruit here: # http://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/software import subprocess import glob import time import cgi import cgitb import os cgitb.enable() def getTempStr(tempStrFile): fin = open(tempStrFile) contents = fin.read() fin.close() return contents os.system("python /home/pi/mytherm/GetTempDaemon.py") print("Content-type: text/html\n\n") # say generating html tempStr = getTempStr('/home/pi/mytherm/temp.txt') setTemp = getTempStr('/home/pi/mytherm/setTemp.txt') htr = getTempStr('/home/pi/mytherm/heaterStatus.txt') pump = getTempStr('/home/pi/mytherm/pumpStatus.txt') htmlFormat = """
The current Pool Temperature is: {tempStr}
The Thermostat is set to: {setTemp}
The Heater is: {htr}
The Pump is: {pump}
""" print(htmlFormat.format(**locals())) # see embedded %s ^ above