Using BaseHTTPServer
Moshe Zadka
moshez at math.huji.ac.il
Fri Apr 28 03:08:09 EDT 2000
On Fri, 28 Apr 2000, Lars von Wedel wrote:
> my CGI project suffers from a lengthy delay for starting up
> python and loading all required modules. I'm thinking about
> setting up a small HTTP server in python itself so that the
> interpreter and all the required modules have to be loaded only
> once.
>
> >From the module documentation it is not clear to me, what I actually
> have to do to catch the GET calls arriving at the server.
>
> 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?
>
> 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.
--
Moshe Zadka <mzadka at geocities.com>.
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com
More information about the Python-list
mailing list