Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: David Palao Newsgroups: comp.lang.python Subject: Re: show instant data on webpage Date: Tue, 26 Jan 2016 17:38:28 +0100 Lines: 39 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de Zv4zxvEfXeLecQay2nZWygoM+dr+1KOH5Z449vjLCj0g== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'cc:addr:python-list': 0.09; '"w")': 0.09; 'output?': 0.09; 'python.': 0.11; '"a")': 0.16; '17:10': 0.16; 'file.close()': 0.16; 'measurement': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:show': 0.16; 'temp': 0.16; 'true:': 0.16; 'load': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'ok.': 0.22; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'message-id:@mail.gmail.com': 0.27; 'streaming': 0.27; 'measure': 0.29; 'code:': 0.29; 'url:mailman': 0.30; 'url:python': 0.33; 'extract': 0.33; 'values.': 0.33; 'url:listinfo': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'problem.': 0.35; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'anything': 0.38; 'received:209.85.220': 0.38; 'url:mail': 0.40; 'some': 0.40; 'show': 0.62; 'webpage': 0.66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=a2slEZZYwFejtrlfjNStLrvxwrINj1eLBc33d9unTOI=; b=HfmcZYCyXMAibYiNxMpRldm3WIBrUGXs4UCEsFpIUorYnE+hOtL5a+IQUXKetXI3jT wwkVtNvrWuEqNaC4g0sDUmwvpZh5xFyJxvzCdSC125/D1T3CExiiwj8nHOnvtLaXMetU lt+qH8IC9/gzUureZpjAM6S5P69B90NahGkwPOHHf6evf2MyLrNDWblwBhoIC2Fu50mB j2G3J83Bi86wAkga/kH4DnNuWh/NCSNPbaPX/zRB3rLw3/pGOsLJaWpIcVGAyuxrsoCj KS0PNET6vyxxZfwLEny2Qdlu8pPfdeLGswMP8CcU8wIw+dHkBzGYNwRaxHctlx1JJ4xj ivSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=a2slEZZYwFejtrlfjNStLrvxwrINj1eLBc33d9unTOI=; b=dNSy3oIOuxOT1M00YDCGyYU92A4xiuwWJ41eK84goLUscNRafjvIk4ErFlKqkomDEk nsxtRpNdWv6joMUvjrR6Y2x7FLz7XRnhSzznQkxAduPNL7Y3CSLlrXp4ecj+weRMEiNP 3/oDbGjvPBXIkPDc6uKQBV6RF3776BQK/GffKpGd4rkCSmeb4LDilmO3njPNz7h6iUJU YO5auSXs7Dya6ERByaBKUxre/fy0iy2DSkR0d7or5inYH6CUo/bGs11UGk9GzOQZIeUQ HQti7obCi7C0/vsUqyM4SBg7Uodyu/VJRQk9HBQf32KGxFfIP2UTblCm+Ods7OzIcdKj tMYA== X-Gm-Message-State: AG10YOS8Xu+hQZhBY/ldpydagWqzq270LOsHXpGCoCX0mvkVO4ZBVNS1xP1LjmPHQQ6Vzen4+fyJPiXXYdMLPA== X-Received: by 10.55.82.137 with SMTP id g131mr29172492qkb.66.1453826308814; Tue, 26 Jan 2016 08:38:28 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102131 2016-01-26 17:10 GMT+01:00 mustang : > 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