CGIHTTPServer

Alex Martelli aleax at aleax.it
Thu May 1 06:19:21 EDT 2003


Pascal Parent wrote:

> Hi,
> 
> How can I start server on '127.0.0.1:80' ?
> When I call CGIHTTPServer.py, it's start on '0.0.0.0:8000'.

Running on port 80 is easy, just pass it as the only commandline
argument:

python CGIHTTPServer.py 80

(plus the paths to the various files if needed of course).


The test function in module BaseHTTPServer, which is the
one used to test the CGI server too, starts with:

    if sys.argv[1:]:
        port = int(sys.argv[1])
    else:
        port = 8000
    server_address = ('', port)

so you can see that the port is easily changeable, but the
servername is hardcoded.  So, write your own module with
a suitable test function duplicating the functionality of
this one (as called from the CGI server module) but with
more customizability to suit your needs.


Alex





More information about the Python-list mailing list