CGI server by Python

Steve Holden sholden at holdenweb.com
Sun Oct 6 10:54:49 EDT 2002


"Brian Lee" <senux at senux.com> wrote in message
news:mailman.1033864209.1187.python-list at python.org...
> On Sat, Oct 05, 2002 at 02:50:52PM +0000, Alex Martelli wrote:
[...]
> >
> > 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?
>
You correctly understand that PATH_INFO is not intended to contain the path
of the program or CGI script, but rather the *additional* path data (if any)
that the URL contains.

Most servers work it out by examining each mapped comonent of the path. If
the component is a directory, further components still need to be processed.
If it's an executable file then the remained of the path should be placed in
PATH_INFO. Of course there's nothing to say that a URL has to correspond to
the structure of any filestore anyway -- it can be a completely virtual
concept, which is how it's used in chapters 17 and 18 of "Python Web
Programming", for example.

Finally, do remember that the *HTTPServer.py library components are intended
more as a proof-of-concept than as production code. Good luck.

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------






More information about the Python-list mailing list