Using BaseHTTPServer

Chuck Esterbrook echuck at mindspring.com
Mon May 1 18:37:19 EDT 2000


Michael Ströder wrote:
> 
> Moshe Zadka wrote:
> >
> > On Fri, 28 Apr 2000, Lars von Wedel wrote:
> >
> > > I assume that I can use BaseHTTPServer as it is. I just need
> > > to implement a working request handler, right?
> > >
> > > Now comes the more fuzzy part:
> > >
> > > Since I do not want to execute external files but internal methods,
> > > I think I could modify CGIHTTPServer by subclassing it and overriding
> > > its do_GET() method to decode the request directly? Or would I rather
> > > use SimpleHTTPServer, here?
> 
> I also started with CGIHTTPServer which does forking. But I wanted to be
> able to let it run under Windows => forking is not an option. I modified
> all my code to be thread-safe, derived my own handler from
> SimpleHTTPServer.SimpleHTTPRequestHandler and used the
> SocketServer.ThreadingMixIn for running multi-threaded.
> 
> > > Within any of the do_GET methods, how do I access data that has been
> > > sent by the client (...&data1=val1?data2=val2?...)?
> >
> > Use the CGI module <wink>. Just copy the code from CGIHTTPServer to create
> > the dictionary, (not as os.environ), and use the cgi module to parse
> > that dictionary.
> 
> Note: IMHO module cgi is NOT thread-safe (reads sys.stdin and use
> os.environ). I'm using my own module cgiforms.py anyway.

But cgi takes parameters for both those items. sys.stdin and os.environ are just the defaults if you don't specify them.

I know, because I use CGI in my AppServer in Webware.


-Chuck



More information about the Python-list mailing list