Writing files on server through CGI

Christoph Haas email at christoph-haas.de
Sun Apr 9 16:52:40 EDT 2006


On Sun, Apr 09, 2006 at 12:35:21AM -0700, amaltasb at gmail.com wrote:
> I have a CGI script on server which process a form and writes its
> content on a file like
> fp = open(fname, 'w')
> fp.write('<HTML><HEAD><TITLE>Cool
> list</TITLE></HEAD><BODY><H2><CENTER>%s</CENTER></H2><BR><H3><center>%s</center></h3></body></html>
> 
> Its working fine, but will it work if the script recieves thousands of
> request simultaneously.

I assume that's a question. No, it won't. If you open a file for writing no
other program can write to it.

> Can this script writes files simultaneusly or will all the request
> queued and processed one by one.

Sorry, no. What is your intent? Usually you either have CGIs that output
HTML directly or scripts that update an HTML file. But CGIs that write to a
HTML file... that looks pretty uncommon.

Don't worry about updating a static HTML file though. If you are using
a decent web server like Apache it will have the file cached and try to
read it once you are done changing it. But don't use CGIs for that.

 Christoph
-- 
~
~
".signature" [Modified] 1 line --100%--                1,48         All



More information about the Python-list mailing list