CRBasic Example 68. Custom Web Page HTML
'This program example demonstrates the creation of a custom web page that resides in the
'CR1000. In this example program, the default home page is replaced by using WebPageBegin to
'create a file called default.html. The graphic in the web page (in this case, the Campbell
'Scientific logo) comes from a file called SHIELDWEB2.JPG. The graphic file must be copied to
'the CR1000 CPU: drive using File Control in the datalogger support software. A second web
'page is created that contains links to the CR1000 data tables.
'NOTE: The "_" character used at the end of some lines allows a code statement to be wrapped
'to the next line.
Dim Commands As String * 200
Public Time(9), RefTemp,
Public Minutes As String, Seconds As String, Temperature As String
DataTable(CRTemp,True,-1)
DataInterval(0,1,Min,10)
Sample(1,RefTemp,FP2)
Average(1,RefTemp,FP2,False)
EndTable
'Default HTML Page
WebPageBegin("default.html",Commands)
HTTPOut("<html>")
HTTPOut("<style>body {background-color: oldlace}</style>")
HTTPOut("<body><title>Campbell Scientific CR1000 Datalogger</title>")
HTTPOut("<h2>Welcome To the Campbell Scientific CR1000 Web Site!</h2>")
HTTPOut("<tr><td style=" + CHR(34) +"width: 290px" + CHR(34) + ">")
HTTPOut("<a href=" + CHR(34) + "http://www.campbellsci.com" + CHR(34) + ">")
HTTPOut("<img src="+ CHR(34) +"/CPU/SHIELDWEB2.jpg"+ CHR(34) + "width=" + _
CHR(34) +"128"+CHR(34)+"height="+CHR(34)+"155"+ CHR(34) + "class=" + _
CHR(34) +"style1"+ CHR(34) +"/></a></td>")
HTTPOut("<p><h2> Current Data:</h2></p>")
HTTPOut("<p>Time: " + time(4) + ":" + minutes + ":" + seconds + "</p>")
HTTPOut("<p>Temperature: " + Temperature + "</p>")
HTTPOut("<p><h2> Links:</h2></p>")
HTTPOut("<p><a href="+ CHR(34) +"monitor.html"+ CHR(34)+">Monitor</a></p>")
HTTPOut("</body>")
HTTPOut("</html>")
WebPageEnd
'Monitor Web Page
WebPageBegin("monitor.html",Commands)
HTTPOut("<html>")
HTTPOut("<style>body {background-color: oldlace}</style>")
HTTPOut("<body>")
HTTPOut("<title>Monitor CR1000 Datalogger Tables</title>")
HTTPOut("<p><h2>CR1000 Data Table Links</h2></p>")
HTTPOut("<p><a href="+ CHR(34) + "command=TableDisplay&table=CRTemp&records=10" + _
CHR(34)+">Display Last 10 Records from DataTable CR1Temp</a></p>")
HTTPOut("<p><a href="+ CHR(34) + "command=NewestRecord&table=CRTemp"+ CHR(34) + _
">Current Record from CRTemp Table</a></p>")
HTTPOut("<p><a href="+ CHR(34) + "command=NewestRecord&table=Public"+ CHR(34) + _
">Current Record from Public Table</a></p>")
421