Creating a Guestbook Application


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 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

  1. Create a new Google Cloud console project or retrieve the project ID of an existing project from the Google Cloud console:

    Go to the Projects page

    Tip: Retrieve a list of your existing project IDs with gcloud.

  2. Install the Google Cloud CLI and then initialize the gcloud CLI:
    Download the SDK

Cloning the project from GitHub

  1. Clone the Guestbook application repository to your local machine:

    git clone https://github.com/GoogleCloudPlatform/appengine-guestbook-python.git
  2. Go to the directory that contains the sample code:

    cd appengine-guestbook-python
    

Building and running locally

To build and run the sample locally:

  1. Start the local development web server by running the following command from the appengine-guestbook-python directory:

    python3 CLOUD_SDK_ROOT/bin/dev_appserver.py ./
    

    The development web server runs and listens for requests on port 8080.

  2. 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.

  3. Stop the development server by pressing Control+C.