Last active
December 26, 2015 08:49
-
-
Save jcarbaugh/7124789 to your computer and use it in GitHub Desktop.
Start a local server. Specify server and port.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PORT=8000 | |
IP=127.0.0.1 | |
while getopts p: opt; do | |
case $opt in | |
i) | |
IP=$OPTARG | |
echo "Setting IP address to $IP" | |
;; | |
p) | |
PORT=$OPTARG | |
echo "Setting port to $PORT" | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
;; | |
esac | |
done | |
shift $((OPTIND - 1)) | |
if [ -e "manage.py" ] | |
then | |
python manage.py runserver $IP:$PORT | |
elif [ -e "web.py" ] | |
then | |
python web.py | |
elif [ -e "Procfile" ] | |
then | |
foreman start -p $IP | |
else | |
LANG=${1:-"python"} | |
case "$LANG" in | |
python) | |
echo "Starting Python server on port $PORT..." | |
python -m SimpleHTTPServer $PORT | |
;; | |
php) | |
echo "Starting PHP server on port $PORT..." | |
php -S $IP:$PORT | |
;; | |
*) | |
echo "Unable to start server with $PORT" | |
exit 1 | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment