Sunday, January 9, 2011: Serving Files in Current Directory, the Quickest Way « from the old blog archive »

I need to test some HTML files in other web browsers on other computers, but I don't want to temporarily move/copy/symlink these files to Apache's directory. I found the solution:

From the docs,

python -m SimpleHTTPServer 8000

Serves files in current directory to everyone connecting to port 8000! Change the port number as needed.

So I added this to my .bash_profile.

alias serve="python -m SimpleHTTPServer"

Note: If you don't specify a port number, this one defaults to port 8000. So you can just type serve.