This appendix describes the installation of the Google App Engine Software Development Kit (SDK) under Windows XP and running a simple “Hello, world” application.
The App Engine SDK allows you to run Google App Engine Applications on your local computer. It simulates the runtime environment of the Google App Engine infrastructure.
This excerpt is from Using Google App Engine. With this book, you can build exciting, scalable web applications quickly and confidently, using Google App Engine -- even if you have little or no experience in programming or web development. Using Google App Engine provides an overview of the tools necessary to use Google App Engine, including Python, HTML, Cascading Style Sheets (CSS), and HTTP. You'll also learn what's required to deploy your applications to Google servers.
Download the appropriate install package for the Google App Engine SDK from http://code.google.com/appengine/downloads.html, as shown in Figure A.1, “Downloading Google Application Engine”.
Download the Windows installer and double-click on the GoogleApplicationEngine installer; the setup wizard will launch, as shown in Figure A.2, “Installing Google App Engine”.
Click through the installation wizard, which should install App Engine. If you do not have Python 2.5, it will install Python 2.5 as well. Once the install is complete, you can discard the downloaded installer.
Let’s create a simple application. Make a folder for your
Google App Engine applications. For this example, we’ll use a folder
apps on the desktop:
Settings\csev\Desktop\apps. Make a subfolder in within
Documents and Settings
Using a text editor such as jEdit (http://www.jedit.org), create a file called
app.yaml in the
ae-01-trivial folder, with the following
application: ae-01-trivial version: 1 runtime: python api_version: 1 handlers: - url: /.* script: index.py
If you are looking at a PDF copy of this book, please do not copy and paste these lines into your text editor; you might end up with strange characters. Just type them into your editor.
Then create a file in the
ae-01-trivial folder called
index.py, with three lines of Python:
print 'Content-Type: text/plain' print '' print 'Hello there Jim'
Then start the Command Prompt program by clicking the Windows icon
in the lower left and typing
in the Start Search box. When it selects the Command Prompt item, press
Enter to start the Command Prompt. Use the
cd command to navigate into the
apps directory, as shown in Figure A.3, “Navigating to the application directory”.
Then start the Google App Engine Web Server and run your application using the following command:
\Program Files\Google\google_appengine\dev_appserver.py ae-01-trivial
You can save some typing by using the following sequence,
pressing the Tab key as indicated (these are just shown to make it
TAB. It works because when you type part of
a filename or folder name and press the Tab key, Windows completes the
name for you to save you some typing. It makes more sense after you’ve
tried it for a bit.
Once App Engine starts your application, you will be asked if you
want App Engine to check for updates (type
y) and then, after a few messages, the server
will start up, as shown in Figure A.4, “Starting the application server”.
The last line tells you which port your application is running on and what URL you should use to access your application. In this case, our application is at http://localhost:8080.
Paste http://localhost:8080 into your browser, and you should see your application, as shown in Figure A.5, “Your Google application”.
Just for fun, edit
to change the name Jim to your own name and refresh the page in the
browser to verify your updates.
With two files to edit, there are two general categories
of errors that you may encounter. The first common error is making a
mistake in your
app.yaml file. If
you make a mistake in the
file, App Engine will not start, and you will see an error on the
command line, as shown in Figure A.6, “Error in app.yaml”.
In this instance, the mistake is an incorrect indentation in the
last line in the
When you make a mistake in the
app.yaml file, you must the fix the mistake
and attempt to start the application again.
The second type of error is in the
index.py file. If you make a syntax error in
index.py file, the error will
appear in your browser. The error will make it look like everything has
gone wrong, as shown in Figure A.7, “Syntax error”.
Do not be alarmed. Ignore most of the output and scroll to the very bottom of the error output. The error that you need to see is likely to be the very last line of the output. In this case, there was a Python syntax error on the first line of our one-line application, as shown in Figure A.8, “Finding the syntax error”.
See also http://en.wikipedia.org/wiki/Stack_trace for more information.
If you make a mistake in a file like
index.py, you can just fix the file and
refresh the page in your browser. There is no need to restart the
To shut down the server, go into the window where you started the server and close the window to abort the server. When the server is shut down, you will notice that navigating to http://localhost:8080 will fail because there is no software running on and listening to port 8080.
If you enjoyed this excerpt, buy a copy of Using Google App Engine.
Copyright © 2009 O'Reilly Media, Inc.