Quantcast
Channel: Call a Flask function every few minutes - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Joran Beasley for Call a Flask function every few minutes

$
0
0

flask_app.py add a route to your getStatus method

...@app.route("/myStatus")def getStatus():    state = database().getState()    if state:        status = " On"    else:        status = "Off"    return status ...

page.html use ajax callbacks to populate the div with jquery(or something else if you want)

...<span id="sysStatus" style="font-weight: bold;">{{ status }}</span>......<script>$(document).ready(function() {    setInterval("ajaxd()",10000); // call every 10 seconds});function ajaxd() {   //reload result into element with id "sysStatus"  $("#sysStatus").load("/myStatus", function() {  alert( "Load was performed." ); });}</script>...

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>