Snippets

Ben Buchanan BASH: simple python server

Created by Ben Buchanan
# set up a server from current dir
function server() { # via https://gist.github.com/1525217
    local host
    host=$(hostname)
    local port
    port="${1:-8888}"

    if [[ $(uname -s) == *CYGWIN* ]]
    then
        opencommand="cygstart"
    else
        opencommand="open"
    fi

    echo "ctrl+c to stop server"

    (sleep 1 && ${opencommand} "http://${host}:${port}/")&
    python -m SimpleHTTPServer "$port"
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.