[Tutor] Trying to post sensor readings to the web.

Bill Gillespie billintucson at yahoo.com
Tue Mar 9 10:28:06 EST 2004

Hi Folks!

I have a great, fun and interesting project - but I have no idea what I
am doing! 


I'm trying to learn how to post some sensor data, to a web page, by
running a python cgi program. The objective is that each time I request
the web page, and run the cgi program, the page would display the
current readings for the sensors I am trying to monitor via the web.

I have the sensors data in the form of a log file, but I'm not sure how
to pass those logged sensor variables, to the web page through the cgi

The log file is called "sensor.txt" and the data in it looks like this:
chan0=125, chan1=32, chan2=255, chan3=003, chan4=103, ...
chan0=125, chan1=33, chan2=255, chan3=002, chan4=114, ... 
chan0=123, chan1=33, chan2=254, chan3=004, chan4=124, ...
chan0=125, chan1=30, chan2=255, chan3=000, chan4=136, ...

        for 24 channels total


Here is what I have so far for the cgi program: 

All it can do at this point is generate a time stamp for the web page,
and generate a simple 3 x 8 table. I'm working with python 2.3, running
on a Mandrake 9.2, Linux machine.

monitor_telemetry.py - a cgi program for posting data to a web page

#! /usr/bin/python

import time

timenow = time.ctime(time.time())

print """Content-type: text/html

<title>Current Sensor Readings</title>
<H3>Sensor Readings - Data Page</H3>


<p>Current date and time</p>
<table border=3>

for i in range(3):
    print "<tr>"
    for j in range(8):
        print "<td>%d.%d</td>" % (i,j)
    print "</tr>"

## print the date and time
print timenow
print "<br><br><br>"

print """



Thanks much for any help.


Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster

More information about the Tutor mailing list