Hi,
I'm trying to display a feed on my page that needs to update about every 10
seconds without refreshing the entire page. I get the feed to display but
not as it should.
an other thing is the page loads after 10 seconds and I think the sleep(10)
is responsible for this. I'm not a programmer (yet) so please sort of spoon
feed any help with comments of how and why so I can learn from it.
Thanks,
Ivo
default.py:
import urllib, json
from time import sleep
def index():
Feed = feed()
return dict(Feed=Feed)
def feed()
#all the parameters needed to get the feed
url = 'http://blabla.com/' + currency +'/'
currency = "EUR"
fields = ['return', 'last', 'value']
while True:
try:
f = urllib.urlopen(url)
data = f.read()
feed1 = json.loads(data)
rate = feed1
for field in fields:
rate = rate[field]
rate = float(rate)
except (ValueError, KeyError):
print "unable to parse"
except IOError:
print "unable to access"
sleept(10)
return rate
index.html:
{{extend 'layout.html'}}
<h1>display rate</h1>
{{=Feed}}
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.