Using BaseHTTPServer
Michael Ströder
x_mst at propack-data.com
Fri Apr 28 11:50:05 EDT 2000
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.
See http://web2ldap.de for all of this stuff, especially module
pylib/w2lserver.py for starting the server. Currently I'm working on
letting it run with SSL support with the help of the great M2Crypto
module. Let me know if you want to have a (already working) snapshot of
this...
Ciao, Michael.
More information about the Python-list
mailing list