CGI: Run Script then load page

Skip Montanaro skip at
Sun Aug 5 21:40:17 CEST 2001

    >> #!/usr/bin/env python
    >> print "Status-Code: 301"                        # Moved permanently
    >> print "Location:"     # New location
    >> print ""                                        # Newline ends HTTP header

    Tom> Coming from a perl background I was surprised there isn't a header
    Tom> building function in the cgi module ... any reason behind this, or
    Tom> did they just not think of it?

The cgi module concerns itself with processing client-side input, not
building server-side output.  I guess nobody thought generating the
necessary headers was all that big a deal.  Some modules do concern
themselves with their little niche.  For example, the Cookie module knows
how to generate Set-Cookie HTTP headers.

Skip Montanaro (skip at

More information about the Python-list mailing list