Last Updated: February 25, 2016
·
955
· mateuszgachowski

Bash + Python: Quick WebServer in your current directory

Just put this script into your .bash_profile(Mac) / .bashrc(Linux) file.

#!/usr/bin/env python
#Python web-server
function webserver() {
  open "http://localhost:${1:-8000}" && $(which python) -m SimpleHTTPServer ${1:-8000}
}

Then, when you're in a directory you want to use as server root call the webserver command.

If you want to use a different port than 8000, just pass it as the first parameter

webserver 6734

That's all!