I want to print the output on webpage as soon as the print statement is executed. Here is my code:
#!/usr/bin/python2.7
import sys, time
sys.stdout.write('Content-Type: text/html\n')
sys.stdout.write('\n\n')
print "<html><body>"
print "hi"
sys.stdout.flush()
for i in range(10):
print '<div>%i</div>'%i
sys.stdout.flush()
time.sleep(1)
print "</body></html>"
But I see all output at once only after full script is executed. Am I missing anything?
` instead of `
and tried without any tags also, none worked.
– Dec 02 '16 at 22:22