CGI server by Python

Brian Lee senux at senux.com
Sat Oct 5 20:27:35 EDT 2002


On Sat, Oct 05, 2002 at 02:50:52PM +0000, Alex Martelli wrote:
> Brian Lee wrote:
>         ...
> >> > I tested CGIHTTPServer.py 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 CGIHTTPServer.py -- 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 CGIHTTPServer.py itself mentions, a reference page for
> environment variables expected by CGI scripts can be found at
> http://hoohoo.ncsa.uiuc.edu/cgi/env.html - that page says:
> """
> PATH_INFO 
> 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.

CGIHTTPServer.py 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 
CGIHTTPServer.py

Whe client request follow...

   http://www.senux.com/cgi-bin/a/b/c/test.cgi/test/argument/

$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 - http://www.senux.com/en/




More information about the Python-list mailing list