Easy access to a web server
Python's SimpleHTTPServer is a really easy way to get a localhost up and running. Just type:
python -m SimpleHTTPServer 8888
and your current working directory is running a server at http://localhost:8888/. But typing that is tedious—here's how to make it an alias instead (on a Mac/UNIX install).
echo "alias pysrv='python -m SimpleHTTPServer'" >> ~/.bash_profile
source ~/.bash_profile
Now, you can just type
pysrv 8888
and get a web server. Much easier to remember!
(NOTE: ~/.bashrc is a more traditional place for this, but a default OS X setup has no ~/.bashrc file. If you have one, put the alias there instead of ~/.bash_profile)
Written by Evan Hensleigh
Related protips
3 Responses
Python 3 is simpler: "python -m http.server 8888".
I agree with you that the SimpleHTTPServer Lower and Upper cases are difficult to remember.
That python server is cliche for me :) Also touch is not necessary.
See my tip on how to easily start python's webserver from Nautilus: Simple HTTP server from Nautilus context menu