Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
Javascript not running in Flask template

part of templates/index.html

<script type="text/javascript">
var seconds = 0;
var el = document.getElementById('seconds-counter');

function incrementSeconds() {
    seconds += 1;
    el.innerText = "Online for " + seconds + " seconds.";
}

window.onload = function(){
alert("Bot Online");
setInterval(incrementSeconds, 1000);
}
</script>
<body>
<div id='seconds-counter'>0</div>
</body>

keep_alive.py

from flask import Flask, render_template
from threading import Thread

app = Flask('')

@app.route('/')
def main():
    return render_template('index.html')

def run():
    app.run(host="0.0.0.0", port=8080)
    
def keep_alive():
    server = Thread(target=run)
    server.start()

the window alerts but doesn't start the counter.
for context, this is a discord bot being hosted on replit.
any reason why this doesn't work?

almost 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!