[Tutor] How do you simulate a CGI script locally?
Bob Gailer
ramrom@earthling.net
Fri Dec 13 16:38:19 2002
At 04:30 PM 12/13/2002 +0100, Magnus Lycka wrote:
>If you don't have a web server, you can use this little one:
>#############
># mywebserver.py
>import BaseHTTPServer, SimpleHTTPServer, CGIHTTPServer
>
>class myRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler):
> def is_executable(self, path):
> return self.is_python(path)
>
>if __name__ == '__main__':
> SimpleHTTPServer.test(myRequestHandler, BaseHTTPServer.HTTPServer)
>#############
>
>Put "mywebserver.py" in a directory of your liking.
>
>Put your python CGI script (e.g. script.py) in a subdirectory
>called cgi-bin. (Script name must end .py etc, or you have to
>modify "is_ececutable" above.
>
>Run "mywebserver.py"
>
>Point your browser to "http://localhost:8000/cgi-bin/script.py
That's really cool. So easy!
But then I substituted my static IP address for localhost (example
http://222.111.333.44:8000/cgi-bin/script.py). If the web server is running
the browser hangs saying "loading". If the web server is not running the
browser immediately reports that the connection was refused. What do I need
to fix here?
Bob Gailer
mailto:ramrom@earthling.net
303 442 2625