Closed reghardtp closed 2 years ago
You are passing the data to the template in a variable called reading_data
. I don't see that variable being used in the template code, you only have it in a commented section, actually.
Hi Miguel! Thanks for the really quick reply, appreciate it!
I friend helped me out to resolve this issue. I was decorating the update_data() function as a app.context_processor, while internal to the function I was handling the app context directly. Removing the decorator resolved the issue.
Thanks!
`@app.before_first_request def before_first_request(): threading.Thread(target=update_data).start()
def update_data(): with app.app_context(): while True: time.sleep(2) turbo.push(turbo.replace(render_template('loadavg.html', reading_data=readings_data), target='reading_data_id'))`
where the readings_data list is updated async in a different request.
In the loadavg.html template:
`
ts | RMS1 | RMS2 |
---|---|---|
{{ reading.ts }} | {{ reading.data_1 }} | {{ reading.data_2 }} |
Hi,
So the basic example on the blog post works in full. Updates come through.
I have tried to update this example to replace a list of data, instead of three variables. The template works and renders perfectly. However, as soon as I try to update the list of data, the page never loads.
I have tried a bunch of different ways of getting this done, but none are working.
template:
Remove this function, and the template renders first time.
any help would be great, thanks!