I
I
ingfa2014-06-20 14:50:47
Flask
ingfa, 2014-06-20 14:50:47

How to display a dynamically updated page with Flask?

Dear toasters, I have a question for you.
How to display a dynamically updated page using flask, for example, a
date and time string once per second.

import datetime
import time
while True:
time.sleep(1)
now_time = datetime.datetime.now()
vremya = now_time.strftime("%d\%m\%Y %H:%M:%S")
print vremya

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kfuntov, 2014-06-20
@kfuntov

A fairly common solution is to request the server with some periodicity from the side of the page using Ajax (from JS). Like "did nothing change?" And on the server each time to answer, either - "not", or "yes, this is it." And on JS update it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question