On my HTML page I've got a span that gets the value of the function getStatus():
<span id="sysStatus" style="font-weight: bold;">{{ status }}</span>
The function that returns status:
def getStatus():
state = database().getState()
if state:
status = " On"
else:
status = "Off"
return status
Rendering the html page:
class Tongles(flask.views.MethodView):
def get(self):
return flask.render_template('page.html', status=getStatus())
I would like somehow to dynamically refresh the status of the system, and the text on the span.
How can I recall the function getStatus without reloading the whole page?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…