Develop and deploy Applications using Google App Engine : Tutorial


17 Feb  

About two years back Google launched a platform that enabled developers to develop and host web applications in Google’s web server. Though Google has offered many APIs for the ease of the programmers, many are reluctant to release their apps in Google’s web sphere.

Recently I was talking to a web developer about this and he told me that the interface offered by Google is some what obscure. Well, that is not true. All you need to is to comprehend the way in which the platform works, then you can easily develop applications using this.

This edition of techblog carries a tutorial which will show you how to develop and deploy their applications in Google’s servers. (The process is very easy so that even if you are a beginner in programming, you can try this one.)

Since my usual ID is already registered with the service, I will use another google email id to show you the procedures.

First of all you need to visit the app engine site and sign in using your email id and password.

Once you have done that you will be redirected to a welcome page which will also have a button – ‘Create an Application’ (See the picture below)

 

 signingup for google app engine

 

Click on the button. Now you will be asked you confirm your identity by verifying your phone number. If you are not based in US, select ‘Other’ and enter your mobile number (with the country code).

 

google app engine mobile verification

 

Google will now send you an ‘Authentication Code’ to your mobile via an SMS. Enter the code in the text area (shown below):

 

authentication code from google

 

Now you are a verified user and you can create an application.

Enter the name for your application (‘Application Identifier’) and you may note that this is a unique one (hence check for availability) :

 

create a new application - google app engine

 

You can now enter the ‘Title for your application’ and register the same.

 

register a new application for google app engine

That is all you need to do in that website.

 

Now open a terminal / consol (in Linux)  or Command Prompt (cmd) in Windows and type ‘python’.  Make sure that you have installed python in your system. If you don’t have Python, visit the official site and get a copy.

 installing python

Once you have Python, type ‘python’ to go to its terminal:

 

python terminal

 

You can test your Python installation by just trying to print a line, say:

x= “Some text”

print x

 

programming in python

 

You can exit this by typing exit ()   or by pressing ctrl D.

Now you need Google App Engine Software Development Kit (SDK) for developing and deploying the software. You can download it from this page. You need to download the package that is specific to your system (Windows/Linux/Mac).

 

google app engine sdk download

Also, you may note that there is also a Java version available. But for this tutorial we need a Python version:

Note: If you a novice user using Windows, you may do some the following steps using the Graphical User Interface (GUI) itself

Once you have downloaded the SDK, unzip the file.

 

linux terminal

And create a new directory named ‘GAE’

 

linux commands

Move the unzipped and zipped file to it:

(If you are in Linux , just use cp or mv to copy or move the zip file and then issue the unzip command)

 

unzipping in linux

 

Now you may create a new directory called ‘techblog_googleapp’. And issue the following:

 

mkdir techblog_googleapp

cd ./techblog_googleapp

nano program.py

using nano in ubuntu

 

Now you will see a text editor and you may add the following lines to it and close it (see the footer of editor for the commands, if you are using the terminal in Linux). Windows users may simply create a new file in this directory using notepad:

 

print ‘Content-Type: text/plain’
print ”
print ‘Hello, world!’

 

The above one simply prints the contents.

Similarly create a new file called ‘app.yaml’ and add the following:

 

application: techblog-app
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
  script: program.py

 

This is more like a configuration file using which you can specify your language (Python), version of application (1), name of application and URL patterns to follow (/.* follows all URLS).

Note that you may have to edit the name of the application to that of yours (which you registered it with Google).

That’s it. Coding work is over.

Now you can deploy it locally and test your application in your system:

 

cd ~/GAE/
google_appengine/dev_appserver.py techblog_googleapp/

 

Now you can visit http://localhost:8080 to see your application running!

 

accessing localhost:8080

 

And you can also see the output in the terminal to see what exactly in happening in the background.

 

google app engine - background info

 

Let’s deploy our application to Google’s Server. For that, issue:

 

cd ~/GAE/
google_appengine/appcfg.py update techblog_googleapp/

 

Now you will be asked to enter your Google mail Id and password (which you used for Google app engine).

 

google app engine - upload applications

Once you have done that the SDK will upload your application to Google’s servers.

 

google app engine - version check

 

Once the process is over you will see the output like this:

 

google app engine - uploading

And you can see the uploaded application in the dashboard of your Google app engine account.

 

google app engine - dashboard

 

You will also be able to access the application using the URL provided by Google!

 

google app engine - urls for applications

 

I will be posting advanced level tutorials in the upcoming days. Please leave your email in the text box in top right of this blog. I will mail you once I have new stuffs for you.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Tags: , ,


TechBlog on Facebook

Comments (2)

 

  1. [...] in your Appspot account. This tutorial requires [...]'; digg_skin = ''; After seeing the previous post on Google App Engine, some of my blog readers asked me to write another Google App Engine tutorial [...]

  2. [...] tutorial assumes that the reader has the basic knowledge on Google App Engine (If not, please read this tutorial first). At the very outset itself, let me clarify this point. The native support is only for Java [...]

Leave a Reply