Created
March 31, 2016 07:26
-
-
Save frederickk/b4b14cca2ef5edb542297f75c8565c62 to your computer and use it in GitHub Desktop.
A simple wrapper for running a local instance of Google's Python AppEngine
This file contains hidden or 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
#!/usr/bin/env bash | |
# | |
# Ken Frederick | |
# [email protected] | |
# | |
# http://kennethfrederick.de/ | |
# http://blog.kennethfrederick.de/ | |
# | |
# A simple wrapper for running a local instance of Google's | |
# Python AppEngine | |
# | |
show_help() { | |
cat << EOF | |
-d (default ./) directory for your application and an app.yaml configuration file | |
-p (default 8080) set the port for server | |
-s (default ~/Documents/Development/google-cloud-sdk/platform/google_appengine) | |
set location of Google Cloud SDK | |
-h display this help and exit, for more information about dev_appserver.py | |
visit https://cloud.google.com/appengine/docs/python/tools/devserver | |
$ ./localserver.sh | |
# Launches a python server http://localhost:8080/ with the your app.yaml | |
# in the same directory as this script | |
$ ./localserver.sh -p 9999 | |
# Launches a python server http://localhost:9999/ with the your app.yaml | |
# app in the same directory as this script | |
$ ./localserver.sh -p 9999 -d ./app | |
# Launches a python server http://localhost:9999/ with the your app.yaml | |
# located in "./app" | |
$ ./localserver.sh -s ~/path/to/google-cloud-sdk/bin | |
# Launches a python server http://localhost:9999/ using the AppEngine SDK located at | |
# "~/Documents/Development/google-cloud-sdk/platform/google_appengine" with the your | |
# app.yaml in the same directory as this script | |
EOF | |
} | |
SDK=~/Documents/Development/google-cloud-sdk/platform/google_appengine | |
DIR=./ | |
PORT=8080 | |
while getopts ":s:d:p:h" OPTION | |
do | |
case $OPTION in | |
s) | |
echo "Setting SDK directory to: $OPTARG" | |
SDK=$OPTARG | |
# exit | |
;; | |
d) | |
echo "Running app directory: $OPTARG" | |
DIR=$OPTARG | |
# exit | |
;; | |
p) | |
echo "Setting port to: $OPTARG" | |
PORT=$OPTARG | |
# exit | |
;; | |
h) | |
show_help | |
exit 0 | |
;; | |
esac | |
done | |
echo "Running AppEngine Server..." | |
echo "------------------" | |
$SDK/dev_appserver.py $DIR --port=$PORT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment