Tuesday, 8 January 2013

Google App Engine


Google App Engine lets you run web applications on Google's infrastructure. App engine does not need any servers to be maintained, we just need to upload the application in the framework.
App engine supports programmes written in languages such as java, python ,go etc.

Main features of app engine are:
  • Dynamic web serving, with full support for common web technologies
  • Persistent storage with queries, sorting and transactions
  • Automatic scaling and load balancing
  • APIs for authenticating users and sending email using Google Accounts
  • A fully featured local development environment that simulates Google App Engine on your computer
  • Task queues for performing work outside of the scope of a web request
  • Scheduled tasks for triggering events at specified times and regular interval

App engine in python environment

It is very simple to set up an app engine application written in python. The first step here is to download the python software development kit (SDK) which  includes a web server application that simulates the App Engine environment. You could download the python SDK here
To set up a web application using google app engine, the below given steps are followed:
  1. Sign into the Google App Engine and create an application. A unique application id is selected for each application.
  2. Create a folder named after the application id in your home directory.
  3. Add file named app.yaml containing the following code.
application: app_id
version: 1
api_version: 1
runtime: python
handlers:

- url: /.*
  script: main.py 
here app_id represents the application id selected.

     4.  Create a file named main.py containing the following code

import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext.webapp import Request
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template

class main1(webapp.RequestHandler):
 def get(self):
           self.response.out.write(template.render("exampleprogram.html",{})) 
  
def main():
    app = webapp.WSGIApplication([
        (r'.*',main1)], debug=True)
    wsgiref.handlers.CGIHandler().run(app)

if __name__ == "__main__":
    main()where exampleprogramm.html represents the application program.
Testing and uploading the application
As the first step,to enable the web server, the following command is used.
google_appengine/dev_appserver.py "path"
The path set will be the path to application id directory.

To verify the output of the application, paste the below given url in your browser.

http://localhost:8080/
Once the desired output is produced, you can upload the application to google app engine using the following command.

appcfg.py update "path"
Here also, the path given will be the path to application id directory.
That finishes the work and the application will be available in the address http://your_app_id.appspot.com.

No comments:

Post a Comment