Solution
from flask import Flask, render_template
import time
import threading
msg = "msg1"
# utility to change msg variable
def change_msg(delay=20):
time.sleep(delay)
global msg
msg = "msg2"
app = Flask(__name__)
@app.route("/")
def home():
return render_template("home.html")
@app.route("/index.html")
def user():
return render_template("index.html", msg=msg)
if __name__ == "__main__":
# spawn a thread that changes value of msg after a delay
t = threading.Thread(target=change_msg)
t.start()
app.run(port=7654, debug=True)