Skip to content

Instantly share code, notes, and snippets.

@frederickk
Created March 31, 2016 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frederickk/b4b14cca2ef5edb542297f75c8565c62 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash
#
# Ken Frederick
# ken.frederick@gmx.de
#
# 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