Lessons‎ > ‎

Hello CGI App

In this lesson, we will confirm the correct installation of the App Engine development environment.  This example is just a copy of the first Hello, World application from the App Engine web site.

From the command line, execute the following command to run the development web server using the Hello, World application:

C:\src\aebootcamp\lessons>test hello-cgi
C:\src\aebootcamp\lessons>dev_appserver.py -p 8080 --clear_datastore hello-cgi
INFO     2010-03-05 23:11:44,944 appengine_rpc.py:157] Server: appengine.google.com
INFO     2010-03-05 23:11:44,951 appcfg.py:348] Checking for updates to the SDK.
WARNING  2010-03-05 23:11:46,071 datastore_file_stub.py:443] Could not read datastore data from c:\users\mike\appdata\lo
cal\temp\dev_appserver.datastore
INFO     2010-03-05 23:11:46,174 dev_appserver_main.py:478] Running application helloworld on port 80: http://localhost:
80
INFO     2010-03-05 23:11:48,686 dev_appserver.py:3038] "GET / HTTP/1.1" 200 -
INFO     2010-03-05 23:11:48,694 dev_appserver_index.py:205] Updating C:\src\aebootcamp\lessons\hello-webapp\index.yaml
INFO     2010-03-05 23:11:48,753 dev_appserver.py:3038] "GET /favicon.ico HTTP/1.1" 200 -

Note: When running Python 2.6 on your client, you will see a Deprecation Warning: ... the sha module is deprecated... or ... the md5 module is deprecated.  I haven't found a fix for this - but I think it can be safely ignored.

Then, open a web browser to 


While you can run your application from the command line, you'll probably find it easier to run the development server from within Eclipse (to kill the command line server, hit CTRL-C, then F5 (refresh) the browser window, and type Y to Terminate the batch job).
  1. New Project/Pydev/Pydev Project
  2. Project name: hello-cgi
    Grammer Version: 2.5
    Google App Engine Directory: C:\Program Files\Google\google_appengine
    Uncheck "create default src folder"
  3. Delete src directory (won't be used)
  4. Right click hello-cgi
    New Folder..../Advanced
    Link to folder: C:\src\aebootcamp\lessons
  5. Run/Run Configurations
    Python Run - New (upper left icon)
    1. Main:
      1. Project: hello-cgi
      2. Main module: C:\Program Files\Google\google_appengine\dev_appserver.py
    2. Arguments
      1. Program Arguments: -p 80 --clear_datastore hello-cgi
      2. Working Directory: C:\src\aebootcamp\lessons
  6. Run/Run


You can also run applications using Google's App Engine Launcher (you will find the program icon on your desktop):

  1. File/Add Existing Application: c:\src\aebootcamp\lessons\hello-cgi

Deploying to App Engine (*.appspot.com)

You can now deploy your app to the hosted App Engine to run it from the server.

  1. Click Edit (or open app.yaml) to change your application id to be unique:

    application: aebootcamp-mckoss
    version: hello-cgi
    runtime: python
    api_version: 1

    handlers:
    - url: /.*
      script: helloworld.py


  2. Click the Deploy button in the Launcher
    You can alternatively do command line deployment:

        C:\src\aebootcamp\lessons>deploy hello-cgi

  3. Test your hosted application: e.g., http://hello-cgi.latest.aebootcamp-mckoss.appspot.com/

    Note: I'm using a little trick here.  Normally, your app will be hosted at <your-app>.appspot.com.  But note that multiple versions of your app can be hosted at the same time.  They all share the same data - but can be running different code.  I take advantage of the fact that the version name of an application can be any string (in this case "hello-cgi").  The URL above is loading the hello-cgi *version* of the aebootcamp-mckoss application.  This allows me to run all the sample applications for this course as different versions of the same application.

Comments