How to build and deploy a cloud backend
The official steps are as follows, but see below for a shortcut. The steps may contain errors; it's difficult to remember exactly this long sequence of steps.
- Download the source version of web2py
- Unzip it
- cd web2py
- cp -r applications/welcome applications/backend
- mv examples/app.example.yaml app.yaml
- Edit app.yaml, removing the version and the application/project information.
- cp examples/routes.parametric.example.py routes.py
- Edit routes.py to define 'backend' as the default application.
- Your code now goes into applications/backend/controllers/api.py (create this file, it does not already exist).
Or use this shortcut: download the web2py zip file at the bottom of this page, and just edit applications/backend/controllers/api.py
gcloud config set account luca@ucsc.edu ;; (for example)
gcloud config set project luca-ucsc-teaching-backend ;; (for example)
gcloud auth login
gcloud config set app/promote_by_default false
gcloud components update
- Create a new project. You can choose any name you like, but once you create the project, you can't change the name any more.
- When you create a new project, you will need to create a billing account. You won't be billed unless you use more than your free quota.
- Upload your application. You can use a command line similar to the following one, where the "--promote" flag is used to ensure that the version you have uploaded starts receiving all the traffic:
gcloud app deploy --promote web2py_backend_spring2017/app.yaml
- Your app is then accessible from a URL like
https://yourproject.appspot.com/api/your_function
Unfortunately, the video file was corrupted, and I was not able to salvage it.