Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.

Deploying the Application

This part of the Python Guestbook code walkthrough shows how to deploy the application to App Engine.

This page is part of a multi-page tutorial. To start from the beginning and see instructions for setting up, go to Creating a Guestbook.

Region ID

The REGION_ID is an abbreviated code that Google assigns based on the region you select when you create your app. The code does not correspond to a country or province, even though some region IDs may appear similar to commonly used country and province codes. Including REGION_ID.r in App Engine URLs is optional for existing apps and will soon be required for all new apps.

To ensure a smooth transition, we are slowly updating App Engine to use region IDs. If we haven't updated your Google Cloud project yet, you won't see a region ID for your app. Since the ID is optional for existing apps, you don't need to update URLs or make other changes once the region ID is available for your existing apps.

Learn more about region IDs.

Deploying the app to App Engine

To upload the guestbook app, run the following command from within the appengine-guestbook-python directory of your application where the app.yaml and index.yaml files are located:

gcloud app deploy app.yaml index.yaml

Optional flags:

  • Include the --project flag to specify an alternate Cloud Console project ID to what you initialized as the default in the gcloud tool. Example: --project [YOUR_PROJECT_ID]
  • Include the -v flag to specify a version ID, otherwise one is generated for you. Example: -v [YOUR_VERSION_ID]

The Datastore indexes might take some time to generate before your application is available. If the indexes are still in the process of being generated, you will receive a NeedIndexError message when accessing your app. This is a transient error, so try a little later if at first you receive this error.

To learn more about deploying your app from the command line, see Deploying a Python App.

Viewing your deployed application

To launch your browser and view the app at https://PROJECT_ID.REGION_ID.r.appspot.com, run the following command:

gcloud app browse

What's next

You might want to check out the following features:

For a deeper dive into how App Engine works, see the documentation on the Python Runtime Environment, and request handling and routing.