For the first time, I need to use python with javascript in a practical project. I have a .py file as below, in the course of development and am trying to develop it a step at a time.
Code: Select all
import cherrypy
class DAL_Heater(object):
@cherrypy.expose
def index (self):
return """<html>
<head>
</head>
<body style="background-color:darkgreen;">
<!comment . . . make a container for the whole active display. Colour of container is dark green>
<! header setup>
<div id="header" ><h1 style="text-align:center;font-family:arial;font-size:45px;color:yellow">Heater Control</h1></div>
<div id="spacer1" style="height:40px;width:230px;"</div>
<!ON/OFF visual telltale>
<div id="container2" style="text-align:center;margin-bottom:30px;background-color:yellow;height:100px;width:270px;">
<div id="word1" style="font-size:20px;color:green;margin-top:30px;"> Heater has been switched</font></div>
<div id="heaterstatus" style="font-size:250%;color:green;margin-top:15px;"> OFF</div>
</div>
<div id="spacer2" style="height:30px;width:230px;"</div>
<div id="container3" style="text-align:center;background-color:yellow;height:140px;width:270px; margin- bottom:30;margin-top:30px;float:left; ">
<div id="vapour" style="margin-top:10px;font-size:150%;color:darkblue;"> Vapour temp is now</div>
<div id="tempdata" style="font-size:300%;color:darkblue;">XYZ</font></div>
<div id="tempinf"style="font-size:150%;color:darkblue;"> degrees Farenheit</div>
</div>
<!ON/OFF button below>
<div id="clicking"><button type="button" onclick="onofffunction()" name="ONOFFBTN" style="background-color:white; height:35px;width:350px;margin-top:20px;float.left;border-radius: 25px;font-size:150%;font-color:darkblue;">Toggle Heater ON or OFF</button></div>
<p id="onoff"></p>
<div id="spacer3" style="height:40px;width:30px;"</div>
<!after Ajax and .php setup, do time, duration, measurement interval, etc details>
<div id="footer" style="background-color:#FFA500;height:50px;width:600px;text-align:center;margin-top:20px;float-left;font-size:50%; color:darkblue">
NB See uncoded comments for later action</div>
<script>
function onofffunction()
{
document.getElementById("container2").style.background-color="white";
document.getElementById("heaterstatus").innerHTML = "ON";
document.getElementById("heaterstatus").color:red;
document.getElementById("heaterstatus").font-size:300%;
document.getElementById("heaterstatus").value = "ON";
document.getElementById("heaterstatus").style="background-color:white;
}
</script>
</body>
</html>"""
if __name__ == '__main__':
cherrypy.quickstart(DAL_Heater())