Last Updated: February 25, 2016
· 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!

Say Thanks
Filed Under

Awesome Job

E4857be2 008e 11e8 8271 f03109811178
Software Engineer
San Francisco Bay Area (San Carlos)
Full Time