Last Updated: February 25, 2016
· vinitcool76

Set this alias in your .zshrc and never need anything to serve your files.

This is a super handy trick. Not only does it saves a lot of time wasted to install and configure apache, also you don't need to move/copy your files to the public_html directory.

First setup this alias in your mac/linux boxes: Either Zsh or Bash will do:

function server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
python -m SimpleHTTPServer "$port"

Then, whenever you need to serve a directory just cd and type server

$ cd Website/
$ server

That's it. I think it is a must for web developers, you just want a local server without much fuss.

P.S You must have Python installed.