Display a continuous counter using Python and flask

Viewed 14

I am trying to create a stopwatch using python and flask. I would like to display a counter that starts at 0 and increments by 1 each second.

With my current implementation, it displays 1 and nothing else.

stopwatch = 0

@app.route('/')
def dashboard():
    global stopwatch
    while stopwatch < 10:
        stopwatch +=1
        print(stopwatch)
        sleep(1)
        return str(stopwatch)

How can I display a counter that increments each second and displays the updated value?

0 Answers
Related