CGI server by Python

Brian Lee senux at
Sun Oct 6 02:27:35 CEST 2002

On Sat, Oct 05, 2002 at 02:50:52PM +0000, Alex Martelli wrote:
> Brian Lee wrote:
>         ...
> >> > I tested in Python 2.2 and found that 
> cgi files in
>         ...
> > But I found environmental variable, $PATH_INFO is not match for my
> > code. I searched on Google how PATH_INFO define and how to set
> > the variable in server. But I can't find it and just wonder someone
> > who know it.
> I'm not sure what you mean.  There's one statement:
>         env['PATH_INFO'] = uqrest
> in -- and uqrest is the urllib.unquote'd version
> of 'rest', which is determined at the start of method run_cgi by
> parsing self.cgi_info appropriately.  What is it you can't find, and
> what problems are you experiencing?
> As itself mentions, a reference page for
> environment variables expected by CGI scripts can be found at
> - that page says:
> """
> The extra path information, as given by the client. In other words, scripts 
> can be accessed by their virtual pathname, followed by extra information at 
> the end of this path. The extra information is sent as PATH_INFO. This 
> information should be decoded by the server if it comes from a URL before 
> it is passed to the CGI script.
> """
> So, what is not working as this spec says it should work?

Hi Alex,

Sorry for bad English. in Python does not support to run CGI not only
in /cgi-bin/ but also other(more deeper) directory. I modified the
code to run CGI in other directory(ex: /cgi-bin/a/b/c/test.cgi). But
I don't know how to set $PATH_INFO variable in my modified

Whe client request follow...

$SCRIPT_NAME should be /cgi-bin/a/b/c/test.cgi and $PATH_INFO sholud
be /test/argument/ Then, how do you detect that test.cgi 
is a existing CGI file and the else string(/test/argument/) 
is value for $PATH_INFO ? (This is what I want to ask.)

I thought server can detect the point of CGI script file in client's
request when the server check each file and directory in request. But
it is pretty overloaded, I think.

Something wrong in my knowlegage? Any advice?

Brian Lee -

More information about the Python-list mailing list