Design philosophy of HTTPServer and BaseHTTPRequestHandler

tzuchien <dot> chiu <at> gmail <dot> com tzuchien.chiu at gmail.com
Wed Aug 22 05:50:16 EDT 2007


Hello, everyone.

Several instances of a same script, which accepts parameters and does
a lengthy job, are executed on a remote machine. I want to couple the
script with a tiny HTTP server so that I can connect to the machine
with a browser and monitor the progress of jobs. The HTTP server of
each instance will bind to different ports.

A BaseHTTPRequestHandler-derived class must somehow know the
parameters of each instance/job in order to return instance/job-
specific result back to the client in do_GET. However, there is no way
to pass parameters (of the lengthy job) because the constructor of
HTTPServer expects a BaseHTTPRequestHandler-derived "class", instead
of an "object".

I cannot (or should not) dynamically create a "BaseHTTPRequestHandler-
derived "class" for each instance of the script, right?

Do I misunderstand the design philosophy of HTTPServer and
BaseHTTPRequestHandler, and they should not be used in this way?




More information about the Python-list mailing list