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

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

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

gae launcher

See demo : http://localhost:8888

result

Download Source Code

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

References

  1. GAE Getting Started: Python 2.7
  2. Using Google App Engine SDK with Python 2.7 on Mac OS X 10.6

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
2 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
ArlusManoel LemosGoogle App Engine Tutorial Recent comment authors
newest oldest most voted
trackback
Google App Engine Tutorial

[…] GAE + Python hello world on Mac OS X GAE + Python web hello world example, using GAE launcher. 2. GAE + Struts 1 & 2 […]

Manoel Lemos
Guest
Manoel Lemos

Hi, I’m trying that, but I’m having the following GAE SDK error: *** Running dev_appserver with the following flags: –skip_sdk_update_check=yes –port=8080 –admin_port=8000 Python command: /usr/bin/python2.7 Traceback (most recent call last): File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py”, line 182, in _run_file(__file__, globals()) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py”, line 178, in _run_file execfile(script_path, globals_) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py”, line 695, in main() File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py”, line 688, in main dev_server.start(options) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py”, line 525, in start options.yaml_files) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py”, line 556, in __init__ server_configuration = ServerConfiguration(yaml_path) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py”, line 82, in __init__ self._yaml_path) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py”, line 272, in _parse_configuration return appinfo_includes.ParseAndReturnIncludePaths(f) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/appinfo_includes.py”, line 63, in ParseAndReturnIncludePaths appyaml = appinfo.LoadSingleAppInfo(appinfo_file) File “/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/appinfo.py”,… Read more »

Arlus
Guest
Arlus

Try deleting the special character before the application line in app.yaml. It seems not to be there but just navigate your cursor to the position before a then press backspace to delete it.

Featured Posts