Usually, in an apache cgi-bin file, you response data this way:
print "Content-Type:text/html"
print
print "Hello world"
And the browser shows the result once the script finishes. But what about closing the response (telling the client there's nothing else and close as if the script ended) so the web browser shows the content and python can keep doing other thing?
print "Content-Type:text/html"
print
print urllib.urlopen("staticpage.html").read()
close() ?
do_a_backend_function # browser is not waiting and has showed the static page to the user
I suppose in the first case apache is taking care of that, but in the second I wanna force it. Thanks
Following @furas indications, I can guess I can just do:
print "Content-Type:text/html"
print
print urllib.urlopen("staticpage.html").read()
import sys
sys.stdout.close()
do_a_backend_function() # browser is not waiting and has showed the static page to the user
Instead of using multithreading, which is much more difficult do develop. But I haven't tried it yet, hope someone does.