HttpServer help!

Steve Holden sholden at holdenweb.com
Thu Jun 6 14:55:50 CEST 2002


"Eric Texier" <erict at millfilm.co.uk> wrote in message
news:3CFF4C14.450850D8 at millfilm.co.uk...
> I am trying to get some simple example running locally on my
> machine of http(server/client)  code from the book 'Python & Xml'
> and I am having trouble.
>
> if someone can look at the following script and tell me if
> the problem can be because I don't have the privilege and/or
> I didn't setup my system properly:
> Thanks.
>
> I am running on Linux Red Hat with python2.2.
>
>
> The client code to POST:
> """
> post.py
> """
> from httplib import HTTP
> from urllib  import quote
>
> # establish POST data
> myquote = 'This is my quote: "I think therefore I am."'
>
> # be sure not to quote the key= sequence...
> postdata = "favquote=" + quote(myquote)
>
> print "Will POST ", len(postdata), "bytes:"
> print postdata
>
> # begin HTTP request
>
> #req = HTTP("127.0.0.1")  # change to your IP or localhost
> #req = HTTP("localhost")  # change to your IP or localhost
>
> ##### MY IP address
> req = HTTP("10.16.3.132")  # change to your IP or localhost
>
>
> #req.putrequest("POST", "/c8/favquote.cgi")
> req.putrequest("POST",
> "file:/usr/people/erict/python/srcToolskit/pythonXmlBook/c8/favquote.cgi")
>
> .
Hold it right here. How is a FILE supposed to process the input you are
trying to send it? Your .putrequest() call should give the path to the CGI
script *relative to the server root*, not it's location in the server's file
store.

> .
> .
>
> ##### That the Error after the ruprequest->"#####
> Traceback (most recent call last):
>   File "post.py", line 25, in ?
>     req.putrequest("POST",
> "file:/usr/people/erict/python/srcToolskit/pythonXmlBook/c8/favquote.cgi")
>
>   File "/usr/people/erict/bin//lib/python2.2/httplib.py", line 453, in
> putrequest
>     self.send(str)
>   File "/usr/people/erict/bin//lib/python2.2/httplib.py", line 395, in
> send
>     self.connect()
>   File "/usr/people/erict/bin//lib/python2.2/httplib.py", line 379, in
> connect
>     raise socket.error, msg
> socket.error: (111, 'Connection refused')
>
Sure enough, when the client tries to create a connection, it can't.

[...]

Hope this helps.

regards
-----------------------------------------------------------------------
Steve Holden                                 http://www.holdenweb.com/
Python Web Programming                http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------








More information about the Python-list mailing list