GAE + Python hello world on Mac OS X

In this tutorial, we will show you how to create a simple GAE hello world web project, using Python, on Mac OS X, and run it via Google App Engine Launcher.

Tools used :

  1. Google App Engine SDK for Python (Mac OS X) – 1.7.0
  2. Mac OS X 10.8
  3. Python 2.7
Note
By default, Mac OS X 10.8, has Python 2.7 installed, which makes Google App Engine development more easier.

1. Google App Engine SDK

Visit this Google App Engine SDK for Python, select Mac OS X and start download it.

1.1 Install Google App Engine SDK
Double clicks on the downloaded GoogleAppEngineLauncher-version.dmg file, it will extract the”GoogleAppEngineLauncher” icon, drag it out to a folder that you want GAE SDK to install.

1.2 Run Google App Engine Launcher
Again, double clicks on the “GoogleAppEngineLauncher” icon, follow the wizard guide to complete the installation.

Figure : GoogleAppEngineLauncher – This GAE launcher help you run, deploy and manage your application.

gae launcher example gae launcher example

2. Python Hello World

File : hello.py – Create a simple python file, to display a hello world message.

import webapp2
 
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello World, GAE + Python')
 
app = webapp2.WSGIApplication([('/', MainPage)], debug=True)

File : app.yaml – Create a simple GAE configuration file.

application: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: true
 
handlers:
- url: /.*
script: hello.app

Done.

3. Import, Run and Demo

In GAE launcher, two fingers clicks on the table grid -> select “Add Existing…“, locate the folder contains above Python files.

gae launcher add existing project gae launcher add existing project

Run it and click on “browse” to view the deployed web application.

gae launcher gae launcher

See demo : http://localhost:8888

result result

Download Source Code

Download it – gae-python-hello-world.zip (3 kb)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s