This tutorial shows you how to build and run a sample Python application for App Engine and provides a code walkthrough of the sample code. The sample is a simple guestbook that lets users post messages to a public message board.
Objectives
- Build and test an App Engine app using Python.
- Integrate your application with Google Accounts for user authentication.
- Use the webapp2 framework.
- Use Jinja2 templates.
- Store data in Google Cloud Datastore.
- Deploy your app to App Engine.
Costs
App Engine has generous free quotas that will cover your testing this tutorial in a live production environment.
Before you begin
- Install Python 2.7.
- Create a new Cloud Platform Console project or retrieve the project ID of
an existing project from the Google Cloud Platform Console:
Tip: Retrieve a list of your existing project IDs with gcloud.
- Install and then initialize the Google Cloud SDK.
Listing your Cloud Platform Console project IDs with gcloud
From the command line, run:
gcloud projects list
Cloning the project from GitHub
-
Clone the Guestbook application repository to your local machine:
git clone https://github.com/GoogleCloudPlatform/appengine-guestbook-python.git
-
Go to the directory that contains the sample code:
cd appengine-guestbook-python
Building and running locally
To build and run the sample locally:
-
Start the local development web server by running the following command from the
appengine-guestbook-pythondirectory:dev_appserver.py ./The development web server runs, listening for requests on port 8080.
-
Visit http://localhost:8080/ in your web browser to view the app.
Click Login, then sign in with any email address. The development server accepts any email you supply, valid or not. This same code requires a valid Google Account and email when deployed to production.
-
Stop the development server by pressing Control+C.