The three lines of code you list are python code.
You run the script using python.exe
The first two lines import some python classes from various modules.
The third line creates a "HTTPServer". It then calls the serve_forever() function of the HTTPServer.
See:
http://docs.python.org/py3k/library/http.server.html[
^]
Presumably that function continously listens on the designated port ('localhost', 8000) and handles the requests with SimpleHTTPRequestHandler
See:
http://docs.python.org/library/simplehttpserver.html[
^]
Quote:
This class serves files from the current directory and below, directly mapping the directory structure to HTTP requests.
SimpleHTTPServer doesn't handle CGI files, but just serves static html.
There is a python class that does that:
http://docs.python.org/library/cgihttpserver.html[
^]
However, there isn't any reason you should be using any of those to accomplish your stated goal.
You already have a webserver running (Apache?) -- you should be configuring that to serve the pages you want from the directory you want on the port you want. (See the documentation for your web server to figure out how to do that.)
If you are just trying to learn python for programming web pages, then stick with running them from http://localhost/cgi-bin/myfile.py -- don't bother with trying to run a webserver in python as well.