SlideShare a Scribd company logo
1 of 37
Introduction to Google App Engine Andrea Spadaccini - @lupino3 May 22nd, 2010 -  Catania – Italy [email_address]
Agenda Overview Developing applications with Google App Engine Toy example Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Overview
What is GAE? Google App Engine (GAE) is a service, offered by Google, that allows developers to build applications that can run on Google's infrastructure. It is a form of Cloud Computing. Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Cloud computing Abstraction  of details like hardware configuration, physical location of data, operating system. Internet-based computing. Cloud : metaphor inspired by the drawing used to represent the Internet (and, earlier, the PSTN) in network diagrams Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Cloud computing Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Traditional client/server paradigm Client N Client 1 Server Internet
Cloud computing Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Cloud Computing Client N Client 1 Internet Server Server Server
Cloud layers Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Software as a Service Platform as a Service Infrastructure as a Service HW / Net IaaS Paas SaaS
Cloud layers Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Software as a Service Platform as a Service Infrastructure as a Service HW / Net IaaS Paas SaaS
GAE Features Run dynamic web applications (request / response) Serve static files Data storage (BigTable) Google infrastructure ->  scalability, efficiency Additional features (mail, XMPP, Google Accounts, cron, WebServices, memcache, image manip.) Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
App Engine datastore The  App Engine Datastore  is a distributed efficient storage designed for web applications. Entity : data object to be stored. Contains  attributes  and is identified by a  key . Queries must be run against  indexes . It's not a relational DB. There are  no joins  (or aggregate queries like count(*)). The schema is enforced by the application, not by the database. Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Developing applications with Google App Engine
Getting started ,[object Object],Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine …  which SDK?
Which language? Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Frame taken from  Matrix  (1999)
Which language? Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Which language? Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Hello world! # helloworld.py print  “Content-Type: text/html” print print  “Hello world” # app.yaml application : gtugct-helloworld version : 1 runtime : python api-version : 1 handlers : -  uri : /.* script : helloworld.py Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Taken from  App Engine Intro  – see References
The GAE dev cycle 10  Develop -  <your favourite tools here>   (hint: ViM) 20   Test -  dev_appserver.py 30   Deploy -  appcfg.py 40   Repeat -  GOTO 10 Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine With the Python SDK
Paradigm and features Request / response (max 30 seconds!) URL ↔ script mapping Web Frameworks: GAE comes with  webapp , a Web Framework developed by Google. You can use Django (but not its ORM!). Web-based administration console Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Toy Example
Answr It! Answr.it by Vanni Rizzo, Pierluigi D'Antrassi, Andrea Spadaccini - http://www.answr.it Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Data modeling (I) #  models.py from  google.appengine.ext  import  db class  Answr(db.Model): text = db.StringProperty() rand = db.FloatProperty() def  to_json(self):   return  '{&quot;text&quot; : &quot;%s&quot;}' % self.text @staticmethod def  get_random(): def  add_answr(answr_text, rand = None): Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Data modeling (II) #  models.py (continued) class  ApplicationData(db.Model): name = db.StringProperty() value = db.IntegerProperty() @staticmethod def  getAnswrCounter(): def  incrementAnswrCounter(): ... Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Main page code from  google.appengine.ext  import  webapp from  google.appengine.ext.webapp.util  import  run_wsgi_app from  models  import  Answr class  AnswrApp(webapp.RequestHandler): def  get(self): self.response.headers['Content-Type'] = 'application/json' random_answr = Answr.get_random() self.response.out.write(random_answr.to_json()) application = webapp.WSGIApplication([('/answr', AnswrApp)], debug = True) if   __name__  == '__main__': run_wsgi_app(application) Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
app.yaml application: answr-it version: 10 runtime: python api_version: 1 handlers: - url: /answr script: main.py - url: / static_files: static/index.html upload: static/index.html - url: /css  (same for /img e /js) static_dir: static/css Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Users API from  models  import  Answr from  google.appengine.api  import  users [.. omissis ..] class  PopulatePage(webapp.RequestHandler): def  get(self): user = users.get_current_user() if   not  user: print  &quot;<a href = '%s'>Log in with your Google Account</a>&quot; % users.create_login_url(self.request.path) elif  users.is_current_user_admin(): print  &quot;Populating the DB...&quot; answrs = [ .. omissis .. ]  for  answr_text  in  answrs: Answr.add_answr(answr_text) Answr.add_answr(&quot;Something strange is going on..&quot;, 1.0) else : logging.warning('Unauthorized access to /populate') Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Live demo http://answr-it.appspot.com .. or .. http://www.answr.it Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Twitter bot (cron + WS) # twitterbot.py import  tweepy from  models  import  ApplicationData, Answr # 1. Login auth = tweepy.BasicAuthHandler(&quot;answrit&quot;, &quot;the_password&quot;) api = tweepy.API(auth) logging.info('Login done!') # 2. Follow back who follows me followers = api.followers() friends = api.friends() to_follow = [x  for  x  in  followers  if  x  not   in  friends] for  user  in  to_follow: try : user.follow() except  tweepy.TweepError, e: logging.warning(e) Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Twitter bot (cron + WS) # twitterbot.py  (cont.) # 3. Read last mentions last_id = ApplicationData.getLastAnswredTweetId() if   not  last_id: mentions = api.mentions(count = 200) else : mentions = api.mentions(count = 200, since_id = last_id) # 4. Random answr for  status  in  mentions: answr = Answr.get_random() api.update_status(&quot;@%s %s&quot; % (status.author.screen_name, answr.text), status.id) if  status.id > last_id: last_id = status.id # 5. Save the last ID if  last_id: ApplicationData.setLastAnswredTweetId(last_id) Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Twitter bot (cron + WS) # cron.yaml cron:  - description: answr to people url: /twitterbot schedule: every 1 mins # (part of) app.yaml - url: /twitterbot login: admin script: twitterbot.py Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine DEMO! (if Murphy allows it..) Tweet something to @answrit  (like: @answrit: are you ok?)
Chat bot (XMPP) # (part of) xmpp.py from  google.appengine.api  import  xmpp from  google.appengine.ext  import  webapp from  google.appengine.ext.webapp.util  import  run_wsgi_app from  models  import  Answr class  XMPPHandler(webapp.RequestHandler): def  post(self): message = xmpp.Message(self.request.POST) message.reply(Answr.get_random().text) application  = webapp.WSGIApplication([('/_ah/xmpp/message/chat/', XMPPHandler)], debug=True) Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
Chat bot (XMPP) # (significant part of) app.yaml - url: /_ah/xmpp/message/chat/ script: xmpp.py inbound_services: - xmpp_message Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine DEMO! Add to your XMPP buddy list  [email_address]  (GTalk is fine), and ask him questions!
References http://en.wikipedia.org  - Articles on Cloud Computing, Affero GPL and others  Google Inc – aa.vv. -  “Bigtable: a distributed storage system for structured data”  - OSDI 2006 Dan Sanderson -  “Programming Google App Engine”  - O' Reilly / Google Press – 2009 Google App Engine home page -  http://www.appspot.com Simon Willison -  “I've (probably) been using Google App Engine for a week longer than you have”  - Slides from Barcamp London 4 – 2008” (referred in this document as  App Engine Intro ) Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine
More stuff
No vendor lock-in! Open source implementation of GAE:  AppScale http://appscale.cs.ucsb.edu/ Runs on: ,[object Object]
XEN (?)
KVM Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine Andrea Spadaccini -  @lupino3  – Introduzione a Google App Engine

More Related Content

What's hot

Google app engine - Overview
Google app engine - OverviewGoogle app engine - Overview
Google app engine - Overview
Nathan Quach
 
Google app engine introduction
Google app engine introductionGoogle app engine introduction
Google app engine introduction
rajsandhu1989
 
Introduction to Google App Engine - Naga Rohit S [ IIT Guwahati ] - Google De...
Introduction to Google App Engine - Naga Rohit S [ IIT Guwahati ] - Google De...Introduction to Google App Engine - Naga Rohit S [ IIT Guwahati ] - Google De...
Introduction to Google App Engine - Naga Rohit S [ IIT Guwahati ] - Google De...
Naga Rohit
 

What's hot (20)

Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
I've (probably) been using Google App Engine for a week longer than you have
I've (probably) been using Google App Engine for a week longer than you haveI've (probably) been using Google App Engine for a week longer than you have
I've (probably) been using Google App Engine for a week longer than you have
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Gentle App Engine Intro
Gentle App Engine IntroGentle App Engine Intro
Gentle App Engine Intro
 
Google app engine
Google app engineGoogle app engine
Google app engine
 
Google app engine - Overview
Google app engine - OverviewGoogle app engine - Overview
Google app engine - Overview
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Google App Engine's Latest Features
Google App Engine's Latest FeaturesGoogle App Engine's Latest Features
Google App Engine's Latest Features
 
App Engine Overview @ Google Hackathon SXSW 2010
App Engine Overview @ Google Hackathon SXSW 2010App Engine Overview @ Google Hackathon SXSW 2010
App Engine Overview @ Google Hackathon SXSW 2010
 
Google app engine introduction
Google app engine introductionGoogle app engine introduction
Google app engine introduction
 
Google App Engine (Introduction)
Google App Engine (Introduction)Google App Engine (Introduction)
Google App Engine (Introduction)
 
Google app engine
Google app engineGoogle app engine
Google app engine
 
Google app engine
Google app engineGoogle app engine
Google app engine
 
Introduction to Google App Engine - Naga Rohit S [ IIT Guwahati ] - Google De...
Introduction to Google App Engine - Naga Rohit S [ IIT Guwahati ] - Google De...Introduction to Google App Engine - Naga Rohit S [ IIT Guwahati ] - Google De...
Introduction to Google App Engine - Naga Rohit S [ IIT Guwahati ] - Google De...
 
Google App engine
Google App engineGoogle App engine
Google App engine
 
Google App Engine - Overview #3
Google App Engine - Overview #3Google App Engine - Overview #3
Google App Engine - Overview #3
 
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
 
Google Application Engine
Google Application EngineGoogle Application Engine
Google Application Engine
 
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
#MBLTdev: Разработка backend для мобильного приложения с использованием Googl...
 
App engine cloud_comp_expo_nyc
App engine cloud_comp_expo_nycApp engine cloud_comp_expo_nyc
App engine cloud_comp_expo_nyc
 

Viewers also liked

App Engine Presentation @ SFJUG Sep 2010
App Engine Presentation @ SFJUG Sep 2010App Engine Presentation @ SFJUG Sep 2010
App Engine Presentation @ SFJUG Sep 2010
Chris Schalk
 
Validating Non Functional Requirements
Validating Non Functional RequirementsValidating Non Functional Requirements
Validating Non Functional Requirements
Reuben Korngold
 
What is a service level agreement week7
What is a service level agreement week7What is a service level agreement week7
What is a service level agreement week7
hapy
 
Software Requirements
 Software Requirements Software Requirements
Software Requirements
Zaman Khan
 

Viewers also liked (20)

Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
App Engine Presentation @ SFJUG Sep 2010
App Engine Presentation @ SFJUG Sep 2010App Engine Presentation @ SFJUG Sep 2010
App Engine Presentation @ SFJUG Sep 2010
 
Zope 3 at Google App Engine
Zope 3 at Google App EngineZope 3 at Google App Engine
Zope 3 at Google App Engine
 
Cloud Computing by Fatma Ghacham
Cloud Computing  by  Fatma GhachamCloud Computing  by  Fatma Ghacham
Cloud Computing by Fatma Ghacham
 
Using Google App Engine Python
Using Google App Engine PythonUsing Google App Engine Python
Using Google App Engine Python
 
SISO Presentation: Cloud Ontology
SISO Presentation: Cloud OntologySISO Presentation: Cloud Ontology
SISO Presentation: Cloud Ontology
 
Cloud Computing
Cloud  ComputingCloud  Computing
Cloud Computing
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Jitterbit Harmony Spring’15 cloud integration platform
Jitterbit Harmony Spring’15 cloud integration platformJitterbit Harmony Spring’15 cloud integration platform
Jitterbit Harmony Spring’15 cloud integration platform
 
Accounting for non functional and project requirements - cosmic and ifpug dev...
Accounting for non functional and project requirements - cosmic and ifpug dev...Accounting for non functional and project requirements - cosmic and ifpug dev...
Accounting for non functional and project requirements - cosmic and ifpug dev...
 
AS400 webservices - the adapter create cloud apps in a couple of days
AS400 webservices - the adapter create cloud apps in a couple of daysAS400 webservices - the adapter create cloud apps in a couple of days
AS400 webservices - the adapter create cloud apps in a couple of days
 
Harmony concepts and design guide
Harmony concepts and design guideHarmony concepts and design guide
Harmony concepts and design guide
 
Validating Non Functional Requirements
Validating Non Functional RequirementsValidating Non Functional Requirements
Validating Non Functional Requirements
 
Non functional requirements - checklist
Non functional requirements - checklistNon functional requirements - checklist
Non functional requirements - checklist
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App Engine
 
Sla Agreement
Sla AgreementSla Agreement
Sla Agreement
 
What is a service level agreement week7
What is a service level agreement week7What is a service level agreement week7
What is a service level agreement week7
 
Software Requirements
 Software Requirements Software Requirements
Software Requirements
 

Similar to Introduction to Google App Engine

App engine devfest_mexico_10
App engine devfest_mexico_10App engine devfest_mexico_10
App engine devfest_mexico_10
Chris Schalk
 
Google cloud platform
Google cloud platformGoogle cloud platform
Google cloud platform
rajdeep
 
Easy Web Project Development & Management with Django & Mercurial
Easy Web Project Development & Management with Django & MercurialEasy Web Project Development & Management with Django & Mercurial
Easy Web Project Development & Management with Django & Mercurial
Widoyo PH
 
Python Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - AppenginePython Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - Appengine
Python Ireland
 

Similar to Introduction to Google App Engine (20)

Get up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or lessGet up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or less
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
 
BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
 
Software Project Management
Software Project ManagementSoftware Project Management
Software Project Management
 
App engine devfest_mexico_10
App engine devfest_mexico_10App engine devfest_mexico_10
App engine devfest_mexico_10
 
Google App Engine for Python - Unit01: Basic
Google App Engine for Python - Unit01: BasicGoogle App Engine for Python - Unit01: Basic
Google App Engine for Python - Unit01: Basic
 
Google cloud platform
Google cloud platformGoogle cloud platform
Google cloud platform
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Easy Web Project Development & Management with Django & Mercurial
Easy Web Project Development & Management with Django & MercurialEasy Web Project Development & Management with Django & Mercurial
Easy Web Project Development & Management with Django & Mercurial
 
How to build virtual assistant like Jarvis (in Ironman) with Google Assistant...
How to build virtual assistant like Jarvis (in Ironman) with Google Assistant...How to build virtual assistant like Jarvis (in Ironman) with Google Assistant...
How to build virtual assistant like Jarvis (in Ironman) with Google Assistant...
 
Passo a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel HíbridaPasso a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel Híbrida
 
Sst hackathon express
Sst hackathon expressSst hackathon express
Sst hackathon express
 
Python Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - AppenginePython Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - Appengine
 
Hands on App Engine
Hands on App EngineHands on App Engine
Hands on App Engine
 
Modern Web Applications with Sightly
Modern Web Applications with SightlyModern Web Applications with Sightly
Modern Web Applications with Sightly
 
Android Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdfAndroid Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdf
 
Обход проверки безопасности в магазинах мобильных приложений при помощи платф...
Обход проверки безопасности в магазинах мобильных приложений при помощи платф...Обход проверки безопасности в магазинах мобильных приложений при помощи платф...
Обход проверки безопасности в магазинах мобильных приложений при помощи платф...
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Introduction to Google App Engine

  • 1. Introduction to Google App Engine Andrea Spadaccini - @lupino3 May 22nd, 2010 - Catania – Italy [email_address]
  • 2. Agenda Overview Developing applications with Google App Engine Toy example Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 4. What is GAE? Google App Engine (GAE) is a service, offered by Google, that allows developers to build applications that can run on Google's infrastructure. It is a form of Cloud Computing. Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 5. Cloud computing Abstraction of details like hardware configuration, physical location of data, operating system. Internet-based computing. Cloud : metaphor inspired by the drawing used to represent the Internet (and, earlier, the PSTN) in network diagrams Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 6. Cloud computing Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Traditional client/server paradigm Client N Client 1 Server Internet
  • 7. Cloud computing Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Cloud Computing Client N Client 1 Internet Server Server Server
  • 8. Cloud layers Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Software as a Service Platform as a Service Infrastructure as a Service HW / Net IaaS Paas SaaS
  • 9. Cloud layers Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Software as a Service Platform as a Service Infrastructure as a Service HW / Net IaaS Paas SaaS
  • 10. GAE Features Run dynamic web applications (request / response) Serve static files Data storage (BigTable) Google infrastructure -> scalability, efficiency Additional features (mail, XMPP, Google Accounts, cron, WebServices, memcache, image manip.) Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 11. App Engine datastore The App Engine Datastore is a distributed efficient storage designed for web applications. Entity : data object to be stored. Contains attributes and is identified by a key . Queries must be run against indexes . It's not a relational DB. There are no joins (or aggregate queries like count(*)). The schema is enforced by the application, not by the database. Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 12. Developing applications with Google App Engine
  • 13.
  • 14. Which language? Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Frame taken from Matrix (1999)
  • 15. Which language? Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 16. Which language? Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 17. Hello world! # helloworld.py print “Content-Type: text/html” print print “Hello world” # app.yaml application : gtugct-helloworld version : 1 runtime : python api-version : 1 handlers : - uri : /.* script : helloworld.py Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Taken from App Engine Intro – see References
  • 18. The GAE dev cycle 10 Develop - <your favourite tools here> (hint: ViM) 20 Test - dev_appserver.py 30 Deploy - appcfg.py 40 Repeat - GOTO 10 Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine With the Python SDK
  • 19. Paradigm and features Request / response (max 30 seconds!) URL ↔ script mapping Web Frameworks: GAE comes with webapp , a Web Framework developed by Google. You can use Django (but not its ORM!). Web-based administration console Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 21. Answr It! Answr.it by Vanni Rizzo, Pierluigi D'Antrassi, Andrea Spadaccini - http://www.answr.it Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 22. Data modeling (I) # models.py from google.appengine.ext import db class Answr(db.Model): text = db.StringProperty() rand = db.FloatProperty() def to_json(self): return '{&quot;text&quot; : &quot;%s&quot;}' % self.text @staticmethod def get_random(): def add_answr(answr_text, rand = None): Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 23. Data modeling (II) # models.py (continued) class ApplicationData(db.Model): name = db.StringProperty() value = db.IntegerProperty() @staticmethod def getAnswrCounter(): def incrementAnswrCounter(): ... Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 24. Main page code from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from models import Answr class AnswrApp(webapp.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'application/json' random_answr = Answr.get_random() self.response.out.write(random_answr.to_json()) application = webapp.WSGIApplication([('/answr', AnswrApp)], debug = True) if __name__ == '__main__': run_wsgi_app(application) Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 25. app.yaml application: answr-it version: 10 runtime: python api_version: 1 handlers: - url: /answr script: main.py - url: / static_files: static/index.html upload: static/index.html - url: /css (same for /img e /js) static_dir: static/css Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 26. Users API from models import Answr from google.appengine.api import users [.. omissis ..] class PopulatePage(webapp.RequestHandler): def get(self): user = users.get_current_user() if not user: print &quot;<a href = '%s'>Log in with your Google Account</a>&quot; % users.create_login_url(self.request.path) elif users.is_current_user_admin(): print &quot;Populating the DB...&quot; answrs = [ .. omissis .. ] for answr_text in answrs: Answr.add_answr(answr_text) Answr.add_answr(&quot;Something strange is going on..&quot;, 1.0) else : logging.warning('Unauthorized access to /populate') Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 27. Live demo http://answr-it.appspot.com .. or .. http://www.answr.it Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 28. Twitter bot (cron + WS) # twitterbot.py import tweepy from models import ApplicationData, Answr # 1. Login auth = tweepy.BasicAuthHandler(&quot;answrit&quot;, &quot;the_password&quot;) api = tweepy.API(auth) logging.info('Login done!') # 2. Follow back who follows me followers = api.followers() friends = api.friends() to_follow = [x for x in followers if x not in friends] for user in to_follow: try : user.follow() except tweepy.TweepError, e: logging.warning(e) Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 29. Twitter bot (cron + WS) # twitterbot.py (cont.) # 3. Read last mentions last_id = ApplicationData.getLastAnswredTweetId() if not last_id: mentions = api.mentions(count = 200) else : mentions = api.mentions(count = 200, since_id = last_id) # 4. Random answr for status in mentions: answr = Answr.get_random() api.update_status(&quot;@%s %s&quot; % (status.author.screen_name, answr.text), status.id) if status.id > last_id: last_id = status.id # 5. Save the last ID if last_id: ApplicationData.setLastAnswredTweetId(last_id) Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 30. Twitter bot (cron + WS) # cron.yaml cron: - description: answr to people url: /twitterbot schedule: every 1 mins # (part of) app.yaml - url: /twitterbot login: admin script: twitterbot.py Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine DEMO! (if Murphy allows it..) Tweet something to @answrit (like: @answrit: are you ok?)
  • 31. Chat bot (XMPP) # (part of) xmpp.py from google.appengine.api import xmpp from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from models import Answr class XMPPHandler(webapp.RequestHandler): def post(self): message = xmpp.Message(self.request.POST) message.reply(Answr.get_random().text) application = webapp.WSGIApplication([('/_ah/xmpp/message/chat/', XMPPHandler)], debug=True) Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 32. Chat bot (XMPP) # (significant part of) app.yaml - url: /_ah/xmpp/message/chat/ script: xmpp.py inbound_services: - xmpp_message Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine DEMO! Add to your XMPP buddy list [email_address] (GTalk is fine), and ask him questions!
  • 33. References http://en.wikipedia.org - Articles on Cloud Computing, Affero GPL and others Google Inc – aa.vv. - “Bigtable: a distributed storage system for structured data” - OSDI 2006 Dan Sanderson - “Programming Google App Engine” - O' Reilly / Google Press – 2009 Google App Engine home page - http://www.appspot.com Simon Willison - “I've (probably) been using Google App Engine for a week longer than you have” - Slides from Barcamp London 4 – 2008” (referred in this document as App Engine Intro ) Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 35.
  • 37. KVM Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 38. Cloud Freedom - AGPL Software licenses like the General Public License state rights of those who get the program, not of those who use the program via a network The GNU Affero General Public License (AGPL) require the availability of source code when the licensed code is deployed as a network service. http://www.gnu.org/licenses/agpl-3.0.html Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine
  • 39. Python vs. Java Image taken from stacktrace.it: http://stacktrace.it/2009/05/google-app-engine/ Andrea Spadaccini - @lupino3 – Introduzione a Google App Engine