cgi parser question ?

Alex Martelli aleax at aleax.it
Sat Apr 19 12:15:48 EDT 2003


Geirgat Jonas wrote:

> Hello,
> maybe this isn't the right place to ask this question I know....
> I have written a basic HTTP server in python now I would like it
> to have python CGI support only I haven't found how CGI works

One way to find out is to study the module CGIHTTPServer.py you
get as part of the Python standard library -- compare and contrast
it with the BaseHTTPServer.py that you also get there, and you'll
start seeing what you need to add to support CGI in addition to
basic HTTP serving.

> is it like this a user requests a page you just parse it "python page.py"
> and send to output to the user ?

Normally, what the server does is, when the user requests a page
that the server can somehow identify as connected to a CGI script,
run the CGI script with the environment appropriately prepared,
and send the script's output as the page to the user.  The way a
server identifies a page request as connected to a CGI script, and
which one, is up to the server, of course -- e.g., looking for
"cgi-bin" in the path to the page is one common convention.


> any help, links would also help on this subject

http://hoohoo.ncsa.uiuc.edu/cgi/interface.html


Alex





More information about the Python-list mailing list