Google app engine uses Python. I am still learning Python at the same time programming with GAE! In this post I will be noting down steps to try my first program with Google App Engine.
Prerequisite
You must download the Google App Engine development kit located at at
http://code.google.com/appengine/downloads.html.
The SDK is available for Windows, Mac OS X, and Linux. It also has python 2.5
What is included in the kit?
The kit is pretty comprehensive and includes,
- A web server application to simulate App engine environment
- Local copy of Datastore
- Local copy of Google accounts and ability to get URLs, send email from your computer using APIs
CLIs from SDK
Look for following 2 CLIs once you download the SDK,
- dev_appserver.py The development web server
- appcfg.py Used to upload your app to App Engine
The app I am going to create is known “Hello World” but I promise (to myself) that I will create better app next time to try out some advanced APIs. (may be app for Bulb and Tube
So here it goes,
Create hello.py and put following code,
print ‘Content-Type: text/plain’ print ”
print ‘Hello World!’
Next, you need to have a configuration file called app.yaml.
Create a file in the directory called app.yaml and write it to read as follows:
application: san_hello_world version: 1.0 runtime: python api_version: 1 handlers: – url: /.* script: hello.py
Because the handler script and configuration file are mapping every URL to the handler, the application is done. Trust me! That’s it.
Now you can test the app with the web server included with the App Engine SDK.
Start the web server with the following command:
google_appengine/dev_appserver.py hello/ (where hello is a folder having above 2 files)
Go to browser and run http:/localhost:8080
You can continue to modify files and web server gets notification and updates what is displayed in the browser (ofcouse once your refresh the browser)
Once you develop and test your app, its time to register it with Google. After all main
intention of this app is to run on cloud and not local on my computer.
If this is first time for you, you need to authenticate yourself by providing cell phone number where Google can text you auth code.
The next step is to register the application ID for your application using,
https://appengine.google.com/start/createapp
Once the registration is completed, you access the application by going to
http://application-id.appspot.com.
You are almost done!
To upload your finished application to Google App Engine, run the following command:
appcfg.py update hello
Enter your Google user name and password at the prompts. Now you can see your application on App Engine and all you need to do is open up a web browser and enter
http://application-id.appspot.com.
Note: You can create 10 applications per google account
Love to hear your comments. I will explore some more APIs from GAE and also going to try my hands on Amazon Web Services.
