Sunday, April 28, 2013

Installing and Building Web App with Google App Engine on Ubuntu (Hello World)


As part of the Udacity's web developement course, the problem set 1 required the online student to submit his/her first web app by using Goole app engine. Here are my step-by-step to make "hello word" (actually it is "hello udacity") application by using Google app engine (python version) on Ubuntu 12.04.

What is Google App Engine? From the Google definition, Google App Engine lets you run web applications on Google's infrastructure. App Engine applications are easy to build, easy to maintain, and easy to scale as your traffic and data storage needs grow. With App Engine, there are no servers to maintain: You just upload your application, and it's ready to serve your users

Installation 

Step-by-step:
  1. Download the Google App Engine from http://code.google.com/appengine/downloads.html
  2. Install the Google App Engine, on Ubuntu:
  3. $ unzip google_appengine_1.7.7.zip 
    $ mv google_appengine ~
    
  4. Make path to our Goole App Engine, change the computer name with yours.
  5. export PATH=$PATH:/home/computer_name/google_appengine/
  6. Make the path permanently
  7. /home/computer_name/.profile
    Then, in .profile  once again input the path in step 3:
    export PATH=$PATH:/home/computer_name/google_appengine/

Writing the first App

Step-by-step:
  1. Make your Google App Engine folder, for example
  2. $ mkdir google_appengine/apps
  3. Make the sub-folder in apps with the app project name, for example is mine
  4. $ mkdir google_appengine/apps/btatmaja
  5. Create file app.yaml in folder btatmaja
  6. application: btatmaja
    version: 1
    runtime: python27
    api_version: 1
    threadsafe: false
    
    handlers:
    - url: /.*
      script: index.py
    
  7. Make your first Hello word in index.py
  8. print 'Content-Type: text/plain'
    print ''
    print 'Hello Udacity'

Testing the application

Step-by-step;
  1. Start the Google web server app engine with the following command followed by your app name (folder). Please look at your current directory, and add the additional scripts
  2. dev_appserver.py btatmaja/
    That will start web server app engine, check it in your web browser by typing: localhost:8080/ . If you got the following your web app in local machine is done, continue it to upload in real Google web server. 
Hello world app in local machine
     
  1. Upload your app to real Google web server (Consider you current directory). Fill your Google account and password.
  2. appcfg.py update btatmaja/
    gcloud app deploy btatmaja/*
    gcloud app deploy
  3. It's done. Check the app in http:btatmaja.appspot.com (replace 'btatmaja' with your app name).
Hello world app in Google Appspot


    Update:

    1. As October 2017, I tried this again, now is simple because it has repository for Ubuntu/Debian and can be installed by apt/apt-get. Now we can use `gcloud` inside Ubuntu terminal

    Source:
    1. http://askubuntu.com/questions/123553/how-to-install-google-appengine
    2. http://www.oreillynet.com/pub/a/web-services/excerpts/9780596800697/run-google-app-linux.html
    Related Posts Plugin for WordPress, Blogger...