Skip to content

Instantly share code, notes, and snippets.

@lotsofcode
Last active August 29, 2015 14:19
Show Gist options
  • Save lotsofcode/889909d4389154415ca4 to your computer and use it in GitHub Desktop.
Save lotsofcode/889909d4389154415ca4 to your computer and use it in GitHub Desktop.
py-serv.sh
#!/bin/bash
port_param=$1
port=${port_param:-5555}
function processId {
/bin/ps aux | grep "SimpleHTTPServer $port" | grep -v grep | awk '{print $2}'
}
# kill previous processes
processId | xargs kill -9
# start the python server
/usr/bin/nohup /usr/bin/python -m SimpleHTTPServer $port >/dev/null 2>&1 &
# spit out the process id
echo -n "Server started on port $port, process id "
processId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment