[Most recently updated: Oct 29, 2013.]
One of the sweet things that comes with a Python installation is the ability to start up an http server in just one line. Since just about every modern computer (not counting tablets and phones!) has Python, you almost certainly can start up an http server to serve some files in a chosen directory with one quick line of code.
Go to your terminal. Go to the directory you want to serve HTML files from, then type one of the following, depending on your python version:
python -m SimpleHTTPServer
python -m http.server
Note that the output on your terminal will say:
Serving HTTP on 0.0.0.0 port 8000 ...
The mention of 0.0.0.0 does not mean the web server is listening at that IP address. Rather, it will be listening at 127.0.0.1:8000. The 0.0.0.0 signifies that the web server will respond to requests that end up on that machine no matter the hostname or IP that was requested.
Note that you can start your web server at port nnnn with:
python -m SimpleHTTPServer nnnn
python -m http.server nnnn
which lets you start a server on port nnnn for the current directory with:
This post has been updated a few times to include improved one-liners pointed out by readers as well as for clarity and completeness. I've deleted the original text since it's quite obsolete now. That might make some of the comments indecipherable because of the lack of context, but it's all for the greater good. If you have any comments/suggests/observations, please speak up!