Advertisements

Passing python values to HTML

Postby subhendusc » Thu May 23, 2013 1:20 am

Offline
subhendusc
Posts: 1
Joined: Thu May 23, 2013 1:09 am
When i run the below program from the console , it is showing the data it receives from serial input in the console.
But , I want to display the data in the webpage , maybe in a box. How can I do it?
The python program is
#!python
import time
import cgi
from serial import Serial
import subprocess

ser = Serial('COM4', 115200, timeout=1)
print("connected to: " + ser.portstr)

while True:
# Read a line and convert it from b'xxx\r\n' to xxx
line = ser.readline().decode('utf-8')[:-2]

if line: # If it isn't a blank line
print(line)
if line == '520':
subprocess.call(["xte", "key Up"])
elif line == '620':
subprocess.call(["xte", "key Down"])
elif line == '110':
break

ser.close()


The data is continuously generated as it receives from the sensor. I need to show the last available data