http knowledge sought

Scott David Daniels Scott.Daniels at Acm.Org
Wed Jun 23 18:39:43 CEST 2004

Elaine Jackson wrote:

> I want to run an http server but I don't know how to get started. I've read
> through the documentation for the relevant modules, but I don't have enough http
> knowledge to get the initial spark I need, and I can't seem to track down the
> knowledge in question on the web or at the library. Maybe somebody can point me
> toward some resources?
> In case you feel like answering a specific question, here's one: How does http
> addressing work? I remember reading in a book about dot-separated quadruples of
> numerals, written in decimal but required to be two hexadecimal digits long.
> Problem is, I can't get hold of that book right now.
> Any help will be much appreciated.
> Peace
Probably the simplest thing to do is something like:

Create a file '' in a directory with some .html
(or .htm) files you want to see.  Let's pretend one of the
html files is named 'slithey.html'.  Here is the body (no
indentation in file) of '':

     import SimpleHTTPServer

Open a command line in your OS, go to the directory you chose above,
and on that command line type the python magic incantation to run
a python program.

As the program starts, it will mention a port.  For the purposes of
this recipe, I'll pretend the port number printed out is "8123".
While your program is still running, open a browser.
Into the browser, enter one of the following URLs.
Or, if you know the name of your computer, you can substitute that
for "localhost".  Similarly, if you know the TCP/IP address of your
computer, substitute it for

localhost and are "magic" ways to refer to your own computer.
Neither should be using your actual internet connection (but you
might get a cute page in firefox if you get the port number wrong).

If you don't know your IP number, you can browse to:

which creates a page with your number (every connection needs to
know the number of the other side in order to reply).

explains some basic tcp/ip address stuff (but operational stuff there
is for Microsoft Windows).

-Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-list mailing list