SlideShare a Scribd company logo
1 of 17
Download to read offline
BangPypers June Meetup 2012

Google App Engine with Python

                Deepak Garg
           Citrix R&D, Bengaluru
     deepakgarg.iitg@gmail.com


    Google App Engine with Python by Deepak Garg is licensed under a
     Creative Commons Attribution-ShareAlike 3.0 Unported License.
      Based on a work at www.slideshare.net/khinnu4u/presentations.
Contents
✔   What my App needs ?
✔   App Engine ?
✔   Python for App Engine
✔   Set Up Your Env
✔   app.yaml
✔   Wsgi
✔   Webapp2 framework
✔   Templates
✔   Static Files
✔   DataStore
✔   Admin & DashBoard
✔   App Engine Feature Set
✔   FAQ
What my App needs ?
●   App = Business Logic + IT
●   IT =>
           deploying and maintaining web and db, server
           backup, HA, scale out/in, LB etc. etc..
           Upgrades, licenses
           Monitoring
●   IT efforts remain consistent and similar across
    different apps, Business Logic differs
●   Developers want to focus on the business logic
App Engine ?
✔
    Google App Engine (aka GAE) 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 in Google’s best-of-breed data
    centers around the world
✔   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
✔   GAE is free up to a certain level of consumed resources
✔   Fees are charged for additional storage, bandwidth, or instance hours
Python for App Engine
●   Python → 2.5, 2.7
●   Frameworks → Django, web2py, webapp, cherryPy, pylons
●   External Libraries → jinja2, lxml, numpy, webob, yaml,
    pil, pycrypto, setuptools etc..
Set up Your Env
✔   Install Python :-)
✔
    Download App Engine SDK →
          ➔   a web server application that simulates the App Engine env
          ➔   dev_appserver.py myapp → for a local webserver
          ➔   appcfg.py update myapp → to deploy to the cloud
✔   Install Eclipse   [ Optional ]
✔   Install Pydev and App Engine Eclipse Plugin [ Optional ]

     https://developers.google.com/appengine/downloads
app.yaml
●   specifies runtime configuration → versions, url handlers etc.
                                  application identifier is
application: helloworld          ”helloworld”, name used to
version: 1                       register your application
runtime: python27                with App Engine
api_version: 1                   Uploading application with
threadsafe: true                 diff version no. creates
                                 different versions on the
handlers:                        server
- url: /.*                       code runs in the python27
  script: helloworld.app         runtime environment,
                                 version "1"
                                 app is threadsafe or not

                                 URL Routers → urls matching
                                 the regex are captured
WSGI
A WSGI application is a callable with the following signature:
 def application(environ, start_response)
environ is a dictionary which contains everything in os.environ plus
variables which contain data about the HTTP reqeust.
start_response is a callable which the application calls to set the
status code and headers for a response, before returning the body of
the response.
            start_response(status, response_headers, exc_info=None)


The return value for the WSGI application is an iterable object.
Each item in the iterable is a chunk of the HTTP response body as a
byte string.
Webapp2 framework
●   A webapp2 application has 2 parts:
         ➔   one or more RequestHandler classes that process requests
               and build responses
         ➔   a WSGIApplication instance that routes incoming requests to
               handlers based on the URL


       import webapp2
       class MainPage(webapp2.RequestHandler):
           def get(self):
               self.response.headers['Content-Type'] = 'text/plain'
               self.response.out.write('Hello, webapp World!')
       app = webapp2.WSGIApplication([('/', MainPage)],
                                     debug=True)
Templates
                                                         libraries:
●   Import jinja2 in app.yaml                            - name: jinja2
                                                           version: latest
●   Point jinja2 to your template dir
    jinjadir = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))



●   Load your templates
                      fom = jinjadir.get_template('form.template')

●   Render your templates
                       fom.render({'items':['a', 'b', 'c']})
Static Files
●   create your static directory
                                              ­ url: /mystatic   
●   point to it in app.yaml                     static_dir: mystatic 



                              Deploy
●   register your app_id           https://appengine.google.com/
●   point to it in app.yaml           application: app_id 
                                      version: 1 
●   update version no.
●   upload your app                appcfg.py update myapp



●   browse your app :)         http://app_id.appspot.com/
DataStore
●   Google’s Bigtable high-performance distributed database
●   Not a Relational DB – scales awesomely well !
●   Replicate data across multiple DCs
●   Data is written to the Datastore in objects known as entities.
    Each entity has a key that uniquely identifies it
●   Every entity has a unique identifier
●   An entity can optionally designate another entity as its parent
    and thus form a hierarchy
              Object Oriented Relational DB        DataStore
              Class             Table              Kind
              Object            Record             Entity
              Attribute         Column             Propery

     https://developers.google.com/appengine/docs/python/datastore/entities
DataStore
●   define your entity class       from google.appengine.ext import db

●   create object (entity)         class PyperDB(db.Model):
                                      name = db.StringProperty(multiline=True);
●   put it in db                      status = db.BooleanProperty();
                                      user_id = db.UserProperty();
●   check it in DB viewer             time = db.DateTimeProperty(auto_now_add=True)

                               us = PyperDB(name=val, status=False, user_id=uid)
                               us.put();


●   Model defines a unique id by             key = us.key().id_or_name()
    default for each entity
                                          result = db.GqlQuery("SELECT * "
●   Fetch data using GQL queries                          "FROM PyperDB "
                                                          ”WHERE ANCESTOR IS :1 "
                                          ”ORDER BY date DESC LIMIT 10",key_value)
●   Delete   uis = PyperDB.all()

             for p in uis:
                 p.delete()

https://developers.google.com/appengine/docs/python/datastore/gqlreference
Admin & DashBoard
●   Local Admin console running at http://localhost:9999/_ah/admin
●   GAE Dashboard, logs, DS viewer etc. are used to manage your
    app
GAE Features




https://developers.google.com/appengine/docs/python/apis
FAQ
●   Can I run existing django apps on App Engine ?
●   Can I move my App Engine application to my hosting
    environment ?
            Yes, Look at django-rel (django for non-relational db
              http://www.allbuttonspressed.com/projects/django-nonrel
              http://www.allbuttonspressed.com/projects/djangoappengine
●   Can I run any Python code on App Engine ?
            With certain limitations →
                     cannot write to FS but you can read ( from flat file you
                        uploaded )
                     cannot open a socket, can't make system call,
                     can't respond slowly to requests ( 60 secs )
Many Thanks !

deepakgarg.iitg@gmail.com

         @donji

   github.com/gargdeepak

More Related Content

What's hot

DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalCampDN
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)Chiew Carol
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React NativeDarren Cruse
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performanceAndrew Rota
 
React Native custom components
React Native custom componentsReact Native custom components
React Native custom componentsJeremy Grancher
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Ajinkya Saswade
 
Using Google App Engine Python
Using Google App Engine PythonUsing Google App Engine Python
Using Google App Engine PythonAkshay Mathur
 
Angular js 2
Angular js 2Angular js 2
Angular js 2Ran Wahle
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andevMike Nakhimovich
 
Try Jetpack Compose
Try Jetpack ComposeTry Jetpack Compose
Try Jetpack ComposeLutasLin
 
React Native - Workshop
React Native - WorkshopReact Native - Workshop
React Native - WorkshopFellipe Chagas
 
Build and Distributing SDK Add-Ons
Build and Distributing SDK Add-OnsBuild and Distributing SDK Add-Ons
Build and Distributing SDK Add-OnsDave Smith
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
React Native Workshop - React Alicante
React Native Workshop - React AlicanteReact Native Workshop - React Alicante
React Native Workshop - React AlicanteIgnacio Martín
 

What's hot (20)

DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
Page object pattern
Page object patternPage object pattern
Page object pattern
 
How to React Native
How to React NativeHow to React Native
How to React Native
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React Native
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
 
React Native custom components
React Native custom componentsReact Native custom components
React Native custom components
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI
 
PyUIA 0.3
PyUIA 0.3PyUIA 0.3
PyUIA 0.3
 
Using Google App Engine Python
Using Google App Engine PythonUsing Google App Engine Python
Using Google App Engine Python
 
Angular js 2
Angular js 2Angular js 2
Angular js 2
 
Angular js
Angular jsAngular js
Angular js
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
 
Android dev tips
Android dev tipsAndroid dev tips
Android dev tips
 
Try Jetpack Compose
Try Jetpack ComposeTry Jetpack Compose
Try Jetpack Compose
 
React inter3
React inter3React inter3
React inter3
 
React Native - Workshop
React Native - WorkshopReact Native - Workshop
React Native - Workshop
 
Build and Distributing SDK Add-Ons
Build and Distributing SDK Add-OnsBuild and Distributing SDK Add-Ons
Build and Distributing SDK Add-Ons
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
React Native Workshop - React Alicante
React Native Workshop - React AlicanteReact Native Workshop - React Alicante
React Native Workshop - React Alicante
 

Viewers also liked

Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with PythonBrian Lyttle
 
App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munichdion
 
App Engine for Python Developers
App Engine for Python DevelopersApp Engine for Python Developers
App Engine for Python DevelopersGareth Rushgrove
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con pythonsserrano44
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011Juan Gomez
 
Google app engine python
Google app engine   pythonGoogle app engine   python
Google app engine pythonEueung Mulyana
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpathAlexis Hassler
 
Google datastore & search api
Google datastore & search apiGoogle datastore & search api
Google datastore & search apiGeoffrey Garnotel
 
Google Cloud Platform. Google App Engine
Google Cloud Platform. Google App Engine Google Cloud Platform. Google App Engine
Google Cloud Platform. Google App Engine Kwaye Kant
 

Viewers also liked (11)

Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munich
 
App Engine for Python Developers
App Engine for Python DevelopersApp Engine for Python Developers
App Engine for Python Developers
 
App Engine
App EngineApp Engine
App Engine
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con python
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011
 
Google app engine python
Google app engine   pythonGoogle app engine   python
Google app engine python
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
 
Google datastore & search api
Google datastore & search apiGoogle datastore & search api
Google datastore & search api
 
Google Cloud Platform. Google App Engine
Google Cloud Platform. Google App Engine Google Cloud Platform. Google App Engine
Google Cloud Platform. Google App Engine
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 

Similar to Google app-engine-with-python

Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Runwesley chun
 
Accessing Google Cloud APIs
Accessing Google Cloud APIsAccessing Google Cloud APIs
Accessing Google Cloud APIswesley chun
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
Angular Intermediate
Angular IntermediateAngular Intermediate
Angular IntermediateLinkMe Srl
 
Introduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google CloudIntroduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google Cloudwesley chun
 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and MaintenanceJazkarta, Inc.
 
GoogleDSC_ GHRCE_ flutter_firebase.pptx
GoogleDSC_ GHRCE_  flutter_firebase.pptxGoogleDSC_ GHRCE_  flutter_firebase.pptx
GoogleDSC_ GHRCE_ flutter_firebase.pptxGoogleDeveloperStude22
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginHaehnchen
 
DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기
DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기
DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기SuJang Yang
 
Using google appengine
Using google appengineUsing google appengine
Using google appengineWei Sun
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App EngineVlad Filippov
 
Dgeni documentation generator
Dgeni   documentation generatorDgeni   documentation generator
Dgeni documentation generatorPeter Darwin
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Pythonwesley chun
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React NativeEric Deng
 

Similar to Google app-engine-with-python (20)

Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
 
Django
DjangoDjango
Django
 
Accessing Google Cloud APIs
Accessing Google Cloud APIsAccessing Google Cloud APIs
Accessing Google Cloud APIs
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
Angular Intermediate
Angular IntermediateAngular Intermediate
Angular Intermediate
 
Introduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google CloudIntroduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google Cloud
 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
 
GoogleDSC_ GHRCE_ flutter_firebase.pptx
GoogleDSC_ GHRCE_  flutter_firebase.pptxGoogleDSC_ GHRCE_  flutter_firebase.pptx
GoogleDSC_ GHRCE_ flutter_firebase.pptx
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 Plugin
 
DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기
DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기
DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기
 
Using google appengine
Using google appengineUsing google appengine
Using google appengine
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App Engine
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
Dgeni documentation generator
Dgeni   documentation generatorDgeni   documentation generator
Dgeni documentation generator
 
Google app engine
Google app engineGoogle app engine
Google app engine
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
 

More from Deepak Garg

Foundation launch
Foundation launchFoundation launch
Foundation launchDeepak Garg
 
Developing with-devstack
Developing with-devstackDeveloping with-devstack
Developing with-devstackDeepak Garg
 
NetScaler and advanced networking in cloudstack
NetScaler and advanced networking in cloudstackNetScaler and advanced networking in cloudstack
NetScaler and advanced networking in cloudstackDeepak Garg
 
Openstack India May Meetup
Openstack India May MeetupOpenstack India May Meetup
Openstack India May MeetupDeepak Garg
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Deepak Garg
 
Social coding and Participating in Open Source Communitites
Social coding and Participating in Open Source CommunititesSocial coding and Participating in Open Source Communitites
Social coding and Participating in Open Source CommunititesDeepak Garg
 

More from Deepak Garg (6)

Foundation launch
Foundation launchFoundation launch
Foundation launch
 
Developing with-devstack
Developing with-devstackDeveloping with-devstack
Developing with-devstack
 
NetScaler and advanced networking in cloudstack
NetScaler and advanced networking in cloudstackNetScaler and advanced networking in cloudstack
NetScaler and advanced networking in cloudstack
 
Openstack India May Meetup
Openstack India May MeetupOpenstack India May Meetup
Openstack India May Meetup
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
 
Social coding and Participating in Open Source Communitites
Social coding and Participating in Open Source CommunititesSocial coding and Participating in Open Source Communitites
Social coding and Participating in Open Source Communitites
 

Recently uploaded

Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...HetalPathak10
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptxmary850239
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPCeline George
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 

Recently uploaded (20)

Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERP
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 

Google app-engine-with-python

  • 1. BangPypers June Meetup 2012 Google App Engine with Python Deepak Garg Citrix R&D, Bengaluru deepakgarg.iitg@gmail.com Google App Engine with Python by Deepak Garg is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Based on a work at www.slideshare.net/khinnu4u/presentations.
  • 2. Contents ✔ What my App needs ? ✔ App Engine ? ✔ Python for App Engine ✔ Set Up Your Env ✔ app.yaml ✔ Wsgi ✔ Webapp2 framework ✔ Templates ✔ Static Files ✔ DataStore ✔ Admin & DashBoard ✔ App Engine Feature Set ✔ FAQ
  • 3. What my App needs ? ● App = Business Logic + IT ● IT =>  deploying and maintaining web and db, server  backup, HA, scale out/in, LB etc. etc..  Upgrades, licenses  Monitoring ● IT efforts remain consistent and similar across different apps, Business Logic differs ● Developers want to focus on the business logic
  • 4. App Engine ? ✔ Google App Engine (aka GAE) 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 in Google’s best-of-breed data centers around the world ✔ 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 ✔ GAE is free up to a certain level of consumed resources ✔ Fees are charged for additional storage, bandwidth, or instance hours
  • 5. Python for App Engine ● Python → 2.5, 2.7 ● Frameworks → Django, web2py, webapp, cherryPy, pylons ● External Libraries → jinja2, lxml, numpy, webob, yaml, pil, pycrypto, setuptools etc..
  • 6. Set up Your Env ✔ Install Python :-) ✔ Download App Engine SDK → ➔ a web server application that simulates the App Engine env ➔ dev_appserver.py myapp → for a local webserver ➔ appcfg.py update myapp → to deploy to the cloud ✔ Install Eclipse [ Optional ] ✔ Install Pydev and App Engine Eclipse Plugin [ Optional ] https://developers.google.com/appengine/downloads
  • 7. app.yaml ● specifies runtime configuration → versions, url handlers etc. application identifier is application: helloworld ”helloworld”, name used to version: 1 register your application runtime: python27 with App Engine api_version: 1 Uploading application with threadsafe: true diff version no. creates different versions on the handlers: server - url: /.* code runs in the python27   script: helloworld.app runtime environment, version "1" app is threadsafe or not URL Routers → urls matching the regex are captured
  • 8. WSGI A WSGI application is a callable with the following signature: def application(environ, start_response) environ is a dictionary which contains everything in os.environ plus variables which contain data about the HTTP reqeust. start_response is a callable which the application calls to set the status code and headers for a response, before returning the body of the response. start_response(status, response_headers, exc_info=None) The return value for the WSGI application is an iterable object. Each item in the iterable is a chunk of the HTTP response body as a byte string.
  • 9. Webapp2 framework ● A webapp2 application has 2 parts: ➔ one or more RequestHandler classes that process requests and build responses ➔ a WSGIApplication instance that routes incoming requests to handlers based on the URL import webapp2 class MainPage(webapp2.RequestHandler):     def get(self):         self.response.headers['Content-Type'] = 'text/plain'         self.response.out.write('Hello, webapp World!') app = webapp2.WSGIApplication([('/', MainPage)],                               debug=True)
  • 10. Templates libraries: ● Import jinja2 in app.yaml - name: jinja2   version: latest ● Point jinja2 to your template dir jinjadir = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir)) ● Load your templates fom = jinjadir.get_template('form.template') ● Render your templates fom.render({'items':['a', 'b', 'c']})
  • 11. Static Files ● create your static directory ­ url: /mystatic    ● point to it in app.yaml   static_dir: mystatic  Deploy ● register your app_id https://appengine.google.com/ ● point to it in app.yaml application: app_id  version: 1  ● update version no. ● upload your app appcfg.py update myapp ● browse your app :) http://app_id.appspot.com/
  • 12. DataStore ● Google’s Bigtable high-performance distributed database ● Not a Relational DB – scales awesomely well ! ● Replicate data across multiple DCs ● Data is written to the Datastore in objects known as entities. Each entity has a key that uniquely identifies it ● Every entity has a unique identifier ● An entity can optionally designate another entity as its parent and thus form a hierarchy Object Oriented Relational DB DataStore Class Table Kind Object Record Entity Attribute Column Propery https://developers.google.com/appengine/docs/python/datastore/entities
  • 13. DataStore ● define your entity class from google.appengine.ext import db ● create object (entity) class PyperDB(db.Model): name = db.StringProperty(multiline=True); ● put it in db status = db.BooleanProperty(); user_id = db.UserProperty(); ● check it in DB viewer time = db.DateTimeProperty(auto_now_add=True) us = PyperDB(name=val, status=False, user_id=uid) us.put(); ● Model defines a unique id by key = us.key().id_or_name() default for each entity result = db.GqlQuery("SELECT * " ● Fetch data using GQL queries                 "FROM PyperDB "                 ”WHERE ANCESTOR IS :1 " ”ORDER BY date DESC LIMIT 10",key_value) ● Delete uis = PyperDB.all() for p in uis:     p.delete() https://developers.google.com/appengine/docs/python/datastore/gqlreference
  • 14. Admin & DashBoard ● Local Admin console running at http://localhost:9999/_ah/admin ● GAE Dashboard, logs, DS viewer etc. are used to manage your app
  • 16. FAQ ● Can I run existing django apps on App Engine ? ● Can I move my App Engine application to my hosting environment ?  Yes, Look at django-rel (django for non-relational db http://www.allbuttonspressed.com/projects/django-nonrel http://www.allbuttonspressed.com/projects/djangoappengine ● Can I run any Python code on App Engine ?  With certain limitations →  cannot write to FS but you can read ( from flat file you uploaded )  cannot open a socket, can't make system call,  can't respond slowly to requests ( 60 secs )
  • 17. Many Thanks ! deepakgarg.iitg@gmail.com @donji github.com/gargdeepak