show instant data on webpage
Grobu
snailcoder at retrosite.invalid
Fri Jan 29 23:01:39 EST 2016
On 26/01/16 17:10, mustang wrote:
> I've built a sensor to measure some values.
> I would like to show it on a web page with python.
>
>
> This is an extract of the code:
>
> file = open("myData.dat", "w")
>
> while True:
> temp = sensor.readTempC()
> riga = "%f\n" % temp
> file.write(riga)
> time.sleep(1.0)
>
> file.close()
>
> Until this all ok.
> Then in PHP I read the file and show it on internet. It works ok but...
> First problem. I've to stop the streaming with CTRl-C to load the PHP
> file because if I try to read during measurement I cannot show anything
> (I think because the file is in using).
> How can I show time by time in a webpage the output?
>
Perhaps you could use a Javascript plotting library (like the one at
flotcharts.org), and use Python only as a CGI agent to serve plotting
data when requested by Javascript, at regular intervals?
More information about the Python-list
mailing list