Bruce Eckel example / CGI server for localhost for Windows XP possible?

Piotr Luszczek luszczek1 at
Sat Jan 10 18:25:49 CET 2004

--- Will Stuyvesant <hwlgw at> wrote:
> Is there anybody who can provide simple example code
> like found in
> Fredrik Lundh's Python Standard Library book for
> setting up a CGI
> server for localhost with Python?  Perhaps the
> examples that are
> available work on linux, but not on my Windows XP
> laptop with Python
> 2.3.3: GET works and the first POST works too,
> subsequent POSTs crash.

This is simple:

and seems to work with multiple POSTs. But it doesn't
seem to be able to handle file upload correctly. At
least as this script is concerned:
def main():
    form = cgi.FieldStorage()

    fc = form.getvalue("fc", "")

    print "Content-type: text/html\r\n\r\n",
    print "<html><body>"

    if fc:
        print "File", repr(fc), str(dir(fc))
        fc = form["fc"]
        print "<pre>"
        print fc.file.value
        print "</pre>"

Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes

More information about the Python-list mailing list