Learning objectives
- Learn how to build and deploy an App Engine app, a simple guestbook
Prerequisites
- Basic familiarity with Python
- PC, Mac, or Linux computer with Python 2.7 installed
- The Introduction to App Engine class
- App Engine 101 in Python : the predecessor to this class
Related
Amy Unruh, Dan Sanderson, Oct 2012
Google Developer Relations
Introduction
You can create and manage applications in App Engine using the
Google Developers Console
.
Once you've registered an application ID for your application, you can deploy it at the free App Engine domain
appspot.com
(or use your own domain).
This lesson walks you through registering an application ID and deploying an App Engine application, and shows how to maintain multiple versions of an application.
Registering Your Application
Note: Once you register an application ID, you can delete it, but you can't re-register that same application ID after it has been deleted. You can skip these next steps if you don't want to register an ID at this time.
You create and manage App Engine web applications from the Google Developers Console, at the following URL:
https://console.developers.google.com/
Google App Engine Launcher users can reach this URL by clicking the Dashboard button.
Sign in to App Engine using your Google account. If you do not have a Google account, you can create one with an email address and password.
To create a new application, click the
Create an Application
button. Follow the instructions to register an application ID, a name unique to this application.
Create an HRD application (the default). Then edit the
app.yaml
file and change the value of the
application:
setting from
helloworld
to your registered application ID.
If you elect to use the free
appspot.com
domain name, the full URL for the application will be
http://your_app_id.appspot.com/
. If you prefer, you can use a
custom domain
instead.
Note: The High Replication Datastore (HRD) is required in order to use the Python 2.7 runtime. This is the default data repository when creating new applications.
Uploading the Application
Once you've created an application ID for your application and edited your
app.yaml
file accordingly, you're ready to deploy the application. To use OAuth 2.0 for authentication, execute the command
appcfg.py --oauth2 update helloworld/
or from the project directory, simply
appcfg.py --oauth2 update .
and follow the instructions. Alternately, you can execute:
appcfg.py update .
and enter your Google user name and password at the prompts. You can also click Deploy in the Google App Engine Launcher to deploy your app.
If you have set up two-step verification for your Google account, you'll need to create and enter an application-specific password. Edit Authorizing applications and sites in your security settings .
When the upload has completed, you'll see your application running on App Engine. If you set up
a free
appspot.com
domain name, the URL for your website begins with your application ID:
http://your_app_id.appspot.com
The Administration Console
The App Engine Administration Console is your window into your running applications. From the initial Console page, which lists your applications, click the link for the application you just created. This will take you to the Dashboard view, from which you can get lots of other information about your application as well.
The Administration Console lets you view general statistics for your application, get information about your running instances, view information about Datastore entities and indexes, control who can administer your application, view the status of your cron jobs and task queues, and much else. See the Administration Console Documentation for more information.
In this lesson we want to particularly highlight one useful aspect of the Administration Console: managing multiple versions of your application.
Application Versions
You can deploy more than one version of your application at the same time. This is useful for things like testing new versions before deploying them "live." You can have up to ten versions of each application; once you've reached that limit, you'll need to delete existing versions before you can deploy new ones. Services such as the Datastore and Memcache are shared across all versions of an application.
App Engine retains a separate copy of your application for each version, each with its own copy of
app.yaml
. In addition to specifying the application ID, the
app.yaml
file indicates a version specifier:
application: your_app_id
version: two
The version specifier can contain letters, digits, and hyphens. In the example above, the version is
two
. When the application is uploaded, the version specified in the
app.yaml
file is the one that gets created or replaced by the upload.
One version of an application is always designated as its
default version.
The default version is accessed when
http://your_app_id.appspot.com
is requested (where
your_app_id
is replaced by your actual application ID, the identifier you selected when you created the application). As an administrator of the application, you can change, via the Administration Console, which version is the default. This allows you to test non-default versions before making them the default.
To access non-default versions of your app, include the version specifier in the URL, like this:
http://version.your_app_id.appspot.com
For version
two
, the version-specific URL would be
http://two.your_app_id.com
. If you're accessing your site via HTTPS and get a security warning, append
-dot-
to the version specifier instead of '.'. So for version
two
, the HTTPS URL would look like this:
https://two-dot-your_app_id.appspot.com
Requests for URLs that specify invalid application version IDs are routed to the default version of the application.
To access your application versions in the Administration Console, go to
appengine.google.com
and select the relevant application ID from the list of your applications. Then select
Versions
in the left navigation bar. From this panel, you can delete unwanted versions and change the default version. You can get information about
All Versions
of your application, or you can select the desired version from the
Version
pulldown. Similarly, you can indicate the version for which log and instance information is displayed.
Note: While it's beyond the scope of this class, it is possible to use multiple versions of an application to do traffic splitting .
Summary and Review
In this lesson, you've learned how to create an application ID, edit your
app.yaml
file to reflect that ID, and upload and deploy your application to
appspot.com
.
To test your understanding of this process, try making a minor change to your application and redeploying it. Do you see the change when you reload the application? Next, try changing the application's version specifier when you make a change. Redeploy the application, and in the Administration Console, change the default version to your new version. Reload the application's URL and check that you're getting the new version.
Congratulations! You have completed this class. For more information on the subjects covered here, see the App Engine documentation and other App Engine classes .