" # Something that takes about 5 seconds ti...">

Send data to browser while waiting (Python)

I have the following code

print "Starting stage 1<br>"

# Something that takes about 5 seconds
time.sleep(5)

print "Stage 1 complete"

I consider a script with my browser as part of a web application, the problem is that it displays everything together. I want it to display the initial message first before it starts, and then add the completion message after its completion.

What do I use to transfer information to the browser in this way?

+3
source share
1 answer

Try clearing the output after the first print using sys.stdout. flush ()

+5
source

Source: https://habr.com/ru/post/1706991/


All Articles