0

I want to make a website where people on the site can see an always updating list, but when I try it, the list only updates when they reload the page.

My code is this...

main.py

from flask import Flask, render_template, url_for, request
import time
import threading

list = []

app = Flask('app')

def back():
  while True:
    list.append('thing')
    time.sleep(1)
back = threading.Thread(name='background', target=back)
back.start()

@app.route('/', methods=["GET", 'POST'])
def hometest():
  return render_template('index.html', list=list)

app.run(host='0.0.0.0', port=8080)

index.html

<!Doctype html>


<title>list viewer</title>


<h2>This is the list</h2>
{{ list }}


any idea how I can do this? Thank you!

DRCoder
  • 21
  • 5

0 Answers0