Simple Sample code for http server and client
David Lees
deblNoSpammy at theworld.com
Thu May 24 01:46:25 EDT 2001
OK, I got the simple server going with the baseHTTPServer module going
against someone elses client script. Still would not mind seeing a
pointer to more detailed documentation on the module.
david lees
David Lees wrote:
>
> I just purchased a copy of the new "Python Standard Library" by Lundh
> and am using it for templates to have 2 way communications over a socket
> by http. The example to post data to an HTTP server,
> httplib-example-2.py on pp 189-190 has a small typo. The line
>
> http.putheader("Content-Length", str(len(size)))
>
> should be
>
> http.putheader("Content-Length", str(len(data)))
>
> However, I am trying to modify the example basehttpserver-example-1.py
> (page 198) to handle the reception of the PUT, by adding a new method
> do_PUT. So far I can see all the header information, by printing
> 'self.headers' but am unable to see the data in the PUT. Any help is
> welcome. I am struggeling with the documentation.
>
> It appears that 'rfile' is supposed to be used, but so far all I can do
> is hang on 'readlines'. Section of code is simply:
> x=self.rfile
> print x.readlines()
> I want to put the data in a string and process it before actually
> writing it do disk on the server.
>
> Thanks in advance,
>
> David Lees
> davidL at raqia.com
More information about the Python-list
mailing list