This appendix describes the installation of the Google App Engine Software Development Kit (SDK) under Windows Vista 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.
This appendix describes the installation of the Google App Engine Software Development Kit (SDK) under Windows Vista 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.
Download the appropriate Google App Engine SDK install package from http://code.google.com/appengine/downloads.html as shown in Figure B.1, “Downloading Google Application Engine”.
Download the Windows installer, double-click on the GoogleApplicationEngine installer, and accept any security warning dialog boxes that pop up.
Click through the installation wizard, as shown in Figure B.2, “Installing Google Application Engine”, and it will 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.
Now you need to create a simple application. Make a folder
for your Google App Engine applications. This example installation will
be put into a desktop folder called apps: C:\Users\csev\Desktop\apps. Then make a
subfolder within apps called
ae-01-trivial—the path to this
folder is C:\Users\csev\Desktop\apps\ae-01-trivial.
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
contents:
application: ae-01-trivial version: 1 runtime: python api_version: 1 handlers: - url: /.* script: index.py
If you are reading a PDF version of this book, please do not copy and paste these lines into your text editor—you might end up with strange characters. Instead, just type them into your editor.
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 Chuck'
Then start the Command Prompt program by clicking the Windows icon
in the lower-left and typing Command
in the Start Search box. When the Command Prompt item is highlighted,
press Enter to start the Command Prompt.
Then use the cd command to
navigate into the apps directory,
as shown in Figure B.3, “Navigating to the application directory”.
Start the Google App Engine Web Server and run your application using this command:
"\Program Files\Google\google_appengine\dev_appserver.py" ae-01-trivial
Once App Engine starts with 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 B.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 B.5, “Your Google application”.
Just for fun, edit index.py
to change the name Chuck to your own name and refresh the browser to
verify your updates.
With two files to edit, there are two general categories
of errors that you may encounter. If you make a mistake in the app.yaml file, App Engine will not start, and
you will see an error, as shown in Figure B.6, “Error in app.yaml”.
In this instance, the mistake was an incorrect indentation in the
last line in the app.yaml (line
8).
When you make a mistake in the app.yaml file, you must the fix the mistake
and attempt to start the application again.
If you make a syntax error in the index.py file, the error will appear in your
browser. The error looks bad, as if everything has gone completely
wrong, as shown in Figure B.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 I made a Python syntax error on of the first line of our one-line application, as shown in Figure B.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 your browser. There is no need to restart the server.
If you enjoyed this excerpt, buy a copy of Using Google App Engine.
Copyright © 2009 O'Reilly Media, Inc.