cwrdjw
Last Updated: February 25, 2016
·
960
· futuraprime
B3abad9f36ac1edc3bf80c162f88bb57

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)

Say Thanks
Respond

3 Responses
Add your response

2849
Id

Python 3 is simpler: "python -m http.server 8888".
I agree with you that the SimpleHTTPServer Lower and Upper cases are difficult to remember.

over 1 year ago ·
2855
Photo on 08.01.2013 at 04.15

That python server is cliche for me :) Also touch is not necessary.

over 1 year ago ·
3884
D42a7264714dee5006b9c99d2567a320

See my tip on how to easily start python's webserver from Nautilus: Simple HTTP server from Nautilus context menu

over 1 year ago ·