There are various ways of setting up a simple app on Google Appengine to act as a backing store.
The first thing you need to do is create an appengine application. To do this, go to https://console.developers.google.com/project and create a project.
Warning: if you do this from your @ucsc.edu account, then the project will be associated with the @ucsc.edu domain and you might lose access to it once you graduate. Ok, you can always transfer it later to your @gmail.com account, but better create it under your @gmail.com account to start with, in my opinion.
You need to choose a unique app-id. You can choose something like my-name-my-app or something like that. Do not put your SSN as part of the app-id, I don't need to tell you this but still.
Also, install the Python Google Appengine Launcher from https://cloud.google.com/appengine/downloads.
The first way consists in using the native webapp2 environment provided by Google Appengine.
An example of such an app will be uploaded soon.
The advantage of this approach is the simplicity; the drawback is that it is a little bit harder to produce a web UI that goes with the application. A web UI is often useful for checking the data, and for administration-type functions.
Web2py is a full-featured, easy-to-use Python-based framework for web development. Here are step-by-step instructions to install a web2py app that can act as backing store e.g. for an Android app, complete with sample code.
First, go in some directory, and clone web2py. It's best if you clone it with my "special" modifications, which include packages to convert back and forth from localtime to UTC. To do this, clone this repository: https://bitbucket.org/luca_de_alfaro/appengine_web2py and be sure to be in the branch luca:
git checkout luca
which contains my extra bonus stuff. Then, do the following.
cd appengine_web2py
Edit app.yaml
, replacing luca-teaching
with the app-id of your application.
Once you have installed web2py as above, go into the applications directory:
cd applications
and clone the sample application from https://bitbucket.org/luca_de_alfaro/backingstore .
This app contains some nifty non-standard features. In particular:
logger.info("I got the message")
Field('post_date', 'datetime', default=datetime.utcnow(), requires=datetime_validator)
You can customize the sample app in two ways. Please refer to the quite wonderful Web2py Book if you want to know all the ins and outs of web2py, but the following is some quick advice.
models/tables.py
contains the declarations of the database tables (that reside on the Google Datastore) used by your application. Feel free to add more tables.controllers/default.py
contains the code that processes web requests. To upload the app, first add it to the Google Appengine Launcher. Select File > Add existing application, and give it the root of the web2py directory, which in your case should be appengine_web2py
. You should see your app-id listed. Now when you click Upload, your app will be uploaded to the cloud.
To monitor your app, go to https://console.developers.google.com/project and look at the logs, the Appengine dashboard, and the Datastore Query Viewer.
If you define in default.py a function without arguments such as:
def myfunc():
then you will be able to access it at the URL:
https://yourappid.appspot.com/backingstore/default/myfunc
If you give a value y to variable x, in a POST, or via the URL as in:
https://yourappid.appspot.com/backingstore/default/myfunc?x=y
(where y has to be urlencoded, of course), then you can access the value y of variable x in web2py as request.vars.x .