HttpServer help!

Steve Holden sholden at holdenweb.com
Thu Jun 6 09:51:02 EDT 2002


"Eric Texier" <erict at millfilm.co.uk> wrote in message
news:3CFF6568.7EE613CE at millfilm.co.uk...
> The server and the client run from the same directory.
> and the cgi file is in the same directory.
>
> all the following failled.
> req.putrequest("POST", "favquote.cgi")
> req.putrequest("POST", "/favquote.cgi")
> req.putrequest("POST", "./favquote.cgi")
>
>
> What is the meaning of  *relative to the server root*
>
Well, I was kind of assuming that the server was written to run CGI scripts,
but I think on further examination I was wrong. The "server root" is the
directopry that the server looks in when you request a document like
http://server:port/index.html -- it's the top-level content directory of a
web server, which may have subdirectories, and so on.

>From your server code:

# start the server on port 2112, requires browser URLs
# to be addressed as http://servername:2112/pathtofile
myServer = HTTPServer(('', 2112), myRequestHandler)


This has one obvious implictaion you seem to have overlooked. Your call in
the client

    req = HTTP("10.16.3.132")

is trying to connect to the default port, port 80. You may need to change
this to

    req = HTTP("10.16.3.132:2112")

It looks, from the code of the server, as though *any* POST request will
result in the same output, so the path you request maybe isn't that
important. Although I haven't read Fred's book yet, I am guessing that the
.putrequest() method assumes you are already connected to the server, and
that the HTTP() object will allow you to put a port number after the IP
address.

If this isn't the case, try writing an HTML page containing a form whose
action attribute is something like

    ACTION="10.16.3.132:2112/something"

and see if submitting that displays a response in the browser.

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






More information about the Python-list mailing list