Small, Local Web/CGI Server Advice

Kevin Altis altis at semi-retired.com
Wed May 30 14:59:14 EDT 2001


I realize the post below is probably more than you are interested in, but it
seems like a good time to bring up these issues since I've been working with
CGIHTTPServer.py intensively over the last week.

First of all, I think versions prior to 2.x didn't work at all on Windows,
at least that is what I gather from previous posts. The version that I'm
using with ActiveState Python 2.1 (build 210) works with some caveats:
1. If you want to run CGIs in directories other than the defaults (/cgi-bin
and /htbin) then you'll have to create a subclass and override the
cgi_directories list, but if you want to actually support Python scripts in
any directory such as /somecgi.py then you have to change the logic
currently used to determine whether a request is a CGI or not (more on this
later).
2. If you want to support extensions other than .py and .pyw such as .cgi
then you have to override is_python. I don't know if compiled scripts (.pyc)
are supported or if that requires a more elaborate wrapper?!
3. In order to correctly support binary output and avoid proper pipe
buffering issues under Windows the source needs to be fixed. I submitted
this to sourceforge at
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=427345&group_id=
5470
My patch seems to take care of the problem with binary uploads, but I would
like to see more tests before it is committed as an official fix.
4. There is a very odd interaction between IE 5.x and CGIHTTPServer.py that
causes POSTs to fail, but in a very strange way. After the first GET or POST
request, subsequent POSTs will result in IE automatically doing a second
POST and then IE will report a DNS error for the page, or if the POST
response is very long IE will do a GET on the request URL rather than
failing with a DNS error. I'm still investigating this along with Mark Lutz,
but my guess is someone who understands the underlying popen2 ans
SocketServer source... is going to have to debug this one. The problem is
almost certainly socket-related.
5. CGIHTTPServer.py and BaseHTTPServer.py currently only support HTTP/1.0.
In addition, there is no support for automatically generating a
Content-length, there are likely a number of security holes and there are
definitely performance issues, so at this point I wouldn't recommend using
CGIHTTPServer.py except for teaching, learning and development, preferably
behind a firewall that doesn't give access to the port the server is running
on. However, I would like to see the library upgraded enough to be secure
and an effective alternative to using Apache, IIS, Zope, etc for "personal"
servers, so I hope to contribute to CGIHTTPServer.py ... towards this end.
One simple upgrade I want is to limit accepting requests by IP which would
make it easy to limit requests to only localhost (127.0.0.1)

I have rewritten CGIHTTPServer.py to simplify issues 1 and 2 when
subclassing and also fixes issue 3, but I'm waiting until further testing is
done before submitting it as a replacement.

ka

"Sloth" <mt_horeb at yahoo.com> wrote in message
news:67abb823.0105300435.260f47d2 at posting.google.com...
> I'm attempting to create my first major Python app for a company that
> wants to run Web (HTML) pages and CGI scripts on their salespeople's
> laptop computers.  Basically, the salesperson would run a local Web
> server that allows for basic CGI scripts to be run.  The customer is
> pushing hard that they want to use their Web browser as the client and
> to have a local server serving CGI/HTML that also is running on that
> laptop (that wouldn't have been my first choice, but those are the
> constraints I'm working with...)
>
> I've tried to use CGIHTTPServer, but I am having problems getting that
> to work on Windows ME/98 (using ActiveState Python 2.1 - HTML is
> served just fine, but CGIs cause EXPLORER to crash).  Any advice on a
> small, preferably Python based Web server that I can run that will
> support CGI?  I'd love to use something like Medusa if I could figure
> out how to get it to support CGIs.  I really don't want to use a
> 'large' server like Apache, since I'm really just trying to run a
> lightweight server.
>
> Any advice would be GREATLY appreciated!!!
>
> Thanks,
>
> Jeremy.





More information about the Python-list mailing list