Hello Mardy, thanks a lot for your help. I found the problem. Your suggestion made me look into some things I haven't thought before :-). I don't know if it is a browser/server/mine fault. The problem was that I was sending text/plain and a txt file. I soon as I started sending back to the browser text/html and an html file, I started getting the things I wanted on screen, but the browser still waited for the script to terminate, which resulted in a timeout. After I also closed stdout, everything worked fine. The strange thing is that I tried closing stdout with the plain text before, but it didn't work.
-- http://mail.python.org/mailman/listinfo/python-list