Delivering dynamic content using cgi module
Jan Kybic
Jan.Kybic at epfl.ch
Wed Mar 8 13:45:29 EST 2000
> Assume a single dynamically generated document as following:
> ...
> <pre>Hello</pre>
>
> Content-Type: image/gif
>
> < ---open a .gif file, read data, and print it to stdout -->
>
> Content-Type: image/pjpeg
>
> < ---open a .jpg file, read data, and print it to stdout -->
>
>
> How to deliver it using CGI? A simple example script would be very helpful.
I am not posting an example code because mine is too long and
application specific. But roughly the idea of my approach is to send a
document like:
<pre>Hello</pre>
<img src="0123019230.gif">
<img src="09090909123.jpg">
and to write the two image files on a disk or in a database (which can
be kept in memory. The browser will issue requests for the two images
to your webserver which must be intelligent enough to serve them -
from a disk file or from a database. For this, you need customizable
web server - I used threaded version of BaseHTTPServer with
a request handler from CGIHTTPServer. I use a timer to delete the
temporary files after certain delay.
Hope this helps
Jan
--
-------------------------------------------------------------------------
Jan Kybic <Jan.Kybic at epfl.ch> BIG IOA DMT EPFL Lausanne, Switzerland
http://bigwww.epfl.ch/kybic tel. work +41 (21) 693 5142
For PGP key see my WWW page.
More information about the Python-list
mailing list