Saturday, October 18, 2014

Creating First Python Application Using Google App Engine

In this post we will use App Engine services from Google that provides a free playground for us to develop Python web applications. Google App Engine (often referred to as GAE or simply App Engine) is a platform as a service (PaaS) cloud computing platform for developing and hosting web applications in Google-managed data centers. Applications are sandboxed and run across multiple servers. App Engine offers automatic scaling for web applications—as the number of requests increases for an application, App Engine automatically allocates more resources for the web application to handle the additional demand.

1. Creating Google App Engine Application

We need to register our application with your Google account to https://appengine.google.com/. Hit the “Create Application” button and fill everything in the form. Just set to as is in the form if you do not sure what you are doing. I use “hello-app-engine” for the application name, you should change all the name in this toturial to your application name.

2. Creating Local Application

If you are new to AppEngine or GAE, it is better if you use the Google App Engine Launcher desktop application from your computer. Many other people prefer to use the command line that also provided by App Engine. You can find the launcher in the App Engine SDK installation on your hard drive or use comman line appengine_launcher. We need to create a local application using the SDK with the application name we have created before. Click on menu File > Create New Appliation…
There are 4 files generated by the SDK app.yamlfavicon.icoindex.yaml and main.py. The application uses webapp2 as a Python web framework.
File main.py

File app.yaml

The line script: main.app will execute the app in the main.py file. Click on menu Run and Browse, your browser will opens the web application from localhost with ‘Hello world!’ printed on the page.

3. Deploying Application

You will need to deploy the application to the internet. Click the Deploy button and provide your registered email address and password for the Google App Engine. Now you can visit your site http://your-application-name.appspot.com from your browser. Happy coding!