I am creating a Flask app, and I'm just starting trying to mix flask and javascript, my script is suuuuper easy:
<!DOCTYPE html>
<html>
<body>
<button id="mybtn">click me to start</button>
<p>click the button to start the count</p>
<p id="demo"></p>
<script>
document.getElementById("mybtn").addEventListener("click", startTimer);
var t = 0;
function startTimer(){
var myVar = setInterval(myTimer, 5000);
}
function myTimer() {
t = t + 1;
//var d = new Date();
//var t = d.toLocaleTimeString();
document.getElementById("demo").innerHTML = t;
}
</script>
</body>
</html>
See Question&Answers more detail:os