Cloud Computing Search Engine

Loading

First App Engine WebApp [GAE]

Most people, when writing an introductory article on a new technology start with something like "Hello, World". Well frankly, I find it boring, but its a must. So here is my GAE version of "Hello, World" with a small twist ;)

By now I hope you guys (and gals) must've downloaded the AppEngine SDK and installed it along with the current Python version. These are the steps to be followed to have a small but working WebApp.

1. Create a folder by the name of 'helloworld'.
2. Inside that, create a python source module. Eg:- helloworld.py
3. Add the following code


print 'Content-Type: text/plain'
print ''
print 'Wassup Yo, Google App Engine Rocks'


This simply indicates the code to be run when an HTTP request is received by the server. It just prints out the text specified. The first line is necessary since it indicates to the browser what kind of content it is. Another common header is "text/html" if we embed HTML markup in the response.

4. Each GAE app has a config file known as 'app.yaml' Create a file by this name in the same directory.


application: helloworld
version: 1
runtime: python
api_version: 1

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



Every request to a URL whose path matches the regular expression /.* (all URLs) should be handled by the helloworld.py script. Application ID is 'helloworld'. For now, just leave it as it is. In a production system, it will be a unique ID. Eg: If we have an app with the URL as http://earlence.appspot.com, then the application ID would be 'earlence'. This we obtain by registering on the GAE site.

5. Now you can test it by running the Development Server supplied with the SDK.


google_appengine/dev_appserver.py helloworld/


Use this at the command line. Make sure that your path is configured properly.

6. Now, after this command, the server is listening on port 8080. To see your app in action, fire up any web browser and use this URL


http://localhost:8080/


and Hey presto!!!, you should see the output on the screen.

In the next post, I will outline the WebApp framework which makes it easier to create applications.

For you to try out:

Try embedding HTML markup in the repsonse stream.

Contact me or your professor if you have any problems.

Cheers,
Earlence Fernandes
 

blogger templates 3 columns | Make Money Online