Howto: Run an application on Google App Engine

Creating a new project

I simply started by creating a project template from the google_appengine directory

Here's the files contained in new_project_template:

I only modified main.py and app.yaml

Here's what those files look like:

main.py


#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import webapp2

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.out.write('Hello world!')

app = webapp2.WSGIApplication([('/', MainHandler)],
                              debug=True)


app.yaml

application: 

new-project-template

version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

libraries:
- name: webapp2

  version: "2.5.1"

In main.py I simpl y replaced the words "Hello world!" with "Hello Udacity!" and in app.yaml changed the application name from 'new-project-template' to 'digital.robertson'.

Uploading and running the project

To upload the project I simply typed the following from the command-line:

google_appengine/appcfg.py update digital-robertson/

Th e following command-line output was observed:


Application: digital-robertson; version: 1
Host: appengine.google.com

Starting update of app: digital-robertson, version: 1
Getting current resource limits.
Scanning files on local disk.
Cloning 1 static file.
Cloning 3 application files.
Uploading 1 files and blobs.
Uploaded 1 files and blobs
Compilation starting.
Compilation completed.
Starting deployment.
Checking if deployment succeeded.
Will check again in 1 seconds.
Checking if deployment succeeded.
Will check again in 2 seconds.
Checking if deployment succeeded.
Will check again in 4 seconds.
Checking if deployment succeeded.
Will check again in 8 seconds.
Checking if deployment succeeded.
Deployment successful.
Checking if updated app version is serving.
Completed update of app: digital-robertson, version: 1
Uploading index definitions.

Testing the application

I opened the web browser at http://digital-robertson.appspot.com/ and observed 'Hello, Udacity!'

Resources

Tags:
Source:
1614hrs.txt
Published:
22-04-2012 16:14