Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102131

Re: show instant data on webpage

From David Palao <dpalao.python@gmail.com>
Newsgroups comp.lang.python
Subject Re: show instant data on webpage
Date 2016-01-26 17:38 +0100
Message-ID <mailman.19.1453826317.2338.python-list@python.org> (permalink)
References <n885p7$1el2$1@gioia.aioe.org>

Show all headers | View raw


2016-01-26 17:10 GMT+01:00 mustang <mustang@nomail.it>:
> 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?
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Is this an option?

open("myData.dat", "w").close()

while True:
    temp = sensor.readTempC()
    riga = "%f\n" % temp
    with open("myData.dat", "a") as f:
        f.write(riga)
    time.sleep(1)

Best

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-01-26 17:10 +0100
  Re: show instant data on webpage David Palao <dpalao.python@gmail.com> - 2016-01-26 17:38 +0100
    Re: show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-01-26 18:26 +0100
      Re: show instant data on webpage David Palao <dpalao.python@gmail.com> - 2016-01-27 11:36 +0100
        Re: show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-01-27 16:36 +0100
          Re: show instant data on webpage Joel Goldstick <joel.goldstick@gmail.com> - 2016-01-27 10:49 -0500
            Re: show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-01-27 18:20 +0100
      Re: show instant data on webpage "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> - 2016-01-27 12:02 +0000
        Re: show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-01-27 16:37 +0100
          Re: show instant data on webpage "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> - 2016-01-27 16:47 +0000
            Re: show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-01-27 18:21 +0100
              Re: show instant data on webpage Grant Edwards <invalid@invalid.invalid> - 2016-01-27 17:51 +0000
                Re: show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-01-29 12:48 +0100
                Re: show instant data on webpage Joel Goldstick <joel.goldstick@gmail.com> - 2016-01-29 07:34 -0500
                Re: show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-01-30 21:50 +0100
                Re: show instant data on webpage Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-01-30 21:33 +0000
                Re: show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-01-31 20:19 +0100
                Re: show instant data on webpage Joel Goldstick <joel.goldstick@gmail.com> - 2016-01-31 14:48 -0500
                Re: show instant data on webpage mustang <mustang@NOMAIL.it> - 2016-02-21 18:36 +0100
  Re: show instant data on webpage Grobu <snailcoder@retrosite.invalid> - 2016-01-30 05:01 +0100

csiph-web