Quickstart for App Engine

This page shows you how to deploy a Python App Engine application and view any error details in Stackdriver Error Reporting.

Try the 3-minute interactive tutorial in the Google Cloud Platform Console.
(Look for the Continue button on the right when you get there.)

Before you begin

  1. Sign in to your Google account.

    If you don't already have one, sign up for a new account.

  2. In the Cloud Platform Console, go to the Projects page and select or create a new project.

    Go to the Projects page

  3. Enable billing for your project.

    Enable billing

  4. Open a Cloud Shell for your project. You will see a "Connecting..." message at the bottom of your project's dashboard while the shell starts.

    Open Cloud Shell.

Deploy an App Engine app

The source code for the application is in the GitHub project appengine-helloworld-python.

  1. Clone the project to your workstation:

    git clone https://github.com/GoogleCloudPlatform/appengine-helloworld-python.git
    

    Git returns the following message:

    git clone https://github.com/GoogleCloudPlatform/appengine-helloworld-python.git
    Cloning into 'appengine-helloworld-python'...
    remote: Counting objects: 49, done.
    remote: Total 49 (delta 0), reused 0 (delta 0), pack-reused 49
    Unpacking objects: 100% (49/49), done.
    Checking connectivity... done.
    

  2. Navigate into the project directory:

    cd appengine-helloworld-python
    
  3. Open app.yaml in a text editor and change the application value to the project name you registered in the Cloud Platform Console.

  4. Test your app using the local development server:

    dev_appserver.py .
    

    Navigate to http://localhost:8080. If everything is configured properly, the browser displays "Hello world!" Press CTRL+C to stop the local development server.

  5. Upload your application to App Engine. Replace [PROJECT_ID] with your own project ID:

    appcfg.py -A [PROJECT_ID] -V v1 update .
    
  6. Navigate to http://[PROJECT_ID].appspot.com (replace [PROJECT_ID] with your own project ID). The browser displays "Hello world!"

Introduce an error

To see Error Reporting in action, you need to trigger an error in your application. Error Reporting only displays errors with a level of Error, so for this example you'll try to import a non-existent module.

  1. Open main.py in a text editor.

  2. Edit the first line of code (after the comments) to read:

    import webapp22
    
  3. Save and close the file.

  4. Upload the modified file to App Engine:

    appcfg.py -A [PROJECT_ID] -V v1 update .
    
  5. Navigate to http://[PROJECT_ID].appspot.com (replace [PROJECT_ID] with your own project ID). The browser displays an ImportError:

    Traceback (most recent call last):
      File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
        handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
      File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
        handler, path, err = LoadObject(self._handler)
      File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
        obj = import(path[0])
      File "/base/data/home/apps/s~er-qs-5/v1.391726448590406952/main.py", line 17, in 
        import webapp22
    ImportError: No module named webapp22
    

View the error in Error Reporting

Stackdriver Error Reporting has picked up the error.

  1. Visit Error Reporting in the Cloud Platform Console. The overview page is displayed, showing one error.

  2. Click Auto reload. The errors list reloads itself every 5 seconds.

  3. Reload your application (http://[PROJECT_ID].appspot.com) in your browser. Error Reporting catches the error. Because the stack trace is similar to the first error, Error Reporting batches it with the first error, updating the number of Occurrences and the time graph.

  4. Click the error in the list. The Error Details page appears.

    The details page contains all of the available information about these related errors, including links to the source code when available.

Clean up

To avoid incurring charges to your Google Cloud Platform account for the resources used in this quickstart:

  1. Navigate to the Projects page of the Cloud Platform Console.

  2. Click the trash can icon () next to your project.

  3. Type your project name to confirm the shutdown.

What's next

Send feedback about...

Stackdriver Error Reporting Documentation