SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Google App Engine (GAE)
Wei-Tsung Su (蘇維宗)
ellington.su@gmail.com
06/30/2014 (Ver. 1.0)
Ubiquitous Computing and Ambient Networking Laboratory 1
Change Log
Date Ver. Authors Description
6/30/2014 1.0 Wei-Tsung Su Google App Engine (GAE); GAE for Python; Using Static Files; Google User Service
Ubiquitous Computing and Ambient Networking Laboratory 2
What?
• Google Cloud Platform
– App Engine provides Platform as a Service (PaaS)
– Compute Engine provides Infrastrcture as a Servce (IaaS)
– CloudSQL, Cloud Storage, and Cloud Datastore provide storage options
– BigQuery and Hadoop provide big data processing capability
• Language supported by GAE
– Python, Java, PHP, and GO
– Different languages may provide different features.
Ubiquitous Computing and Ambient Networking Laboratory 3
Why?
• Easily deploy your web services to public
• Seamlessly integrate with other Google services
• Free quotas (https://developers.google.com/appengine/docs/quotas)
– Code & Static Data Store (1GB free)
– Google Cloud Storage (5GB free)
– Blobstore Stored Data (5GB free)
– API access (which depends on different Google API)
– ...
Ubiquitous Computing and Ambient Networking Laboratory 4
How?
• Read Support Documentation
– https://developers.google.com/appengine/
• Try Administration Console
– https://appengine.google.com/
– https://console.developers.google.com
• Download SDK
– https://developers.google.com/appengine/downloads
Start Your Engine
3, 2, 1
Ubiquitous Computing and Ambient Networking Laboratory 5
GAE for Python
Ubiquitous Computing and Ambient Networking Laboratory 6
Setup Development Environment
• Install Python 2.7
– https://www.python.org/download/releases/2.7.7/
• Install App Engine SDK for Python
– https://developers.google.com/appengine/downloads
– Ex. we assume that google_appengine/ is the SDK directory.
• Install Git (optional)
– http://git-scm.com/downloads
Ubiquitous Computing and Ambient Networking Laboratory 7
How GAE for Python Works
• A Python web app interacts with the App Engine web server using
Web Server Gateway Interface (WSGI) protocol.
• WSGI-compatible web application frameworks, such as
– webapp2 (by default, simple)
– Django
– CherryPy
– Pylons
– web.py
– web2py
Ubiquitous Computing and Ambient Networking Laboratory 8
Project Structure of GAE for Python
• Modules
– Dynamic web page generation
– http://webapp-improved.appspot.com/
– Filename: xxx.py (ex. helloword.py)
• Configuration File
– Project configuration
– Routing requests to modules
– https://developers.google.com/appengine/docs/python/config/appconfig
– Filename: app.yaml (壓謀!)
• Ex. we assume that helloworld/ is the project directory
Ubiquitous Computing and Ambient Networking Laboratory 9
Module: helloworld. py
• import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/ html'
self.response.write('Hello, World!')
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
• For security issue, you should disable debug which will display a
stack trace in the browser when a handler raises an exception.
Ubiquitous Computing and Ambient Networking Laboratory 10
Configuration File: app.yaml
• application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.app
• How to test your project locally
– # google_appengine/dev_appserver.py helloworld/
– Test your web app by visiting the URL: http://localhost:8080
Ubiquitous Computing and Ambient Networking Laboratory 11
Hello, World!
Ubiquitous Computing and Ambient Networking Laboratory 12
Using Static Files
• Sometimes, you may put static files, such images, CSS stylesheets,
JavaScript code, and so on, into your web applications.
• For example,
– <img src="/images/logo.png" >
• Unfortunately, you cannot just
create a directory and put the
static files into the directory.
• You also need to add route into
con figuration file: app.yaml
– - url: /images
static_dir: images
Ubiquitous Computing and Ambient Networking Laboratory 13
Google User Service
• Google user service (https://developers.google.com/appengine/docs/python/users/)
• Import user service module
– from google.appengine.api import users
• Get current user
– user = users.get_current_user() # Google Account, Google Apps Account, OpenID
• Access user information
– user.nickname()
– user.email()
– user.user_id()
• Administrator check
– user.is_current_user_admin()
• Create login/logout pages
– users.create_login_url('[destination URL]')
– users.create_logout_url('[destination URL]')
Ubiquitous Computing and Ambient Networking Laboratory 14
Google User Service - Example
• from google.appengine.api import users
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
user = users.get_current_user()
if user:
self.response.headers['Content-Type'] = 'text/ html'
self.response.write('Hello, World, %s!<br>', %(user.nickname()))
self.response.write('<a href="%s">Sign Out</a>'
% users.create_logout_url(self.request.url))
else:
self.redirect(users.create_login_url(self.request.url) )
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
Ubiquitous Computing and Ambient Networking Laboratory 15
Hello, World, User!
Ubiquitous Computing and Ambient Networking Laboratory 16
Deploy Your Application
• Step 1: Create Project in Developer Console
– https://console.developers.google.com
– You will get a random project id (Ex. your-app-id).
– The public URL of your web application will be
• http://your-app-id.appspot.com
• Step 2: Check if the application ID in app.yaml matches your-app-id
– application: your-app-id
• Step 3: Deploy your local project
– #google_appengine/appcfg.py update helloworld/
– Test your web app by visiting the URL: http://your-app-id.appspot.com
Ubiquitous Computing and Ambient Networking Laboratory 17
Q&A
You can clone the sample code by
git clone https://github.com/ucanlab/gae_python_basic_helloworld.git
or visiting
https://github.com/ucanlab/gae_python_basic_helloworld
Ubiquitous Computing and Ambient Networking Laboratory 18

Weitere ähnliche Inhalte

Was ist angesagt?

Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Alex S
 
Tips and tricks for building Large web applications with Drupal
Tips and tricks for building Large web applications with DrupalTips and tricks for building Large web applications with Drupal
Tips and tricks for building Large web applications with DrupalMitzaCeusan
 
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...Dicoding
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js선협 이
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3 ArezooKmn
 
Using and contributing to the next Guice
Using and contributing to the next GuiceUsing and contributing to the next Guice
Using and contributing to the next GuiceAdrian Cole
 
Play Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity StackPlay Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity StackMarcin Stepien
 
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
 
Introducing the (new) Google Docs API (2019)
Introducing the (new) Google Docs API (2019)Introducing the (new) Google Docs API (2019)
Introducing the (new) Google Docs API (2019)wesley chun
 
Cloud Function For Firebase - GITS
Cloud Function For Firebase - GITSCloud Function For Firebase - GITS
Cloud Function For Firebase - GITSYatno Sudar
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web FrameworkDavid Gibbons
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.xJoão Ventura
 
Drupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systemsDrupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systemsAlex S
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesHassan Abid
 
Introduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentIntroduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentColin Su
 
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...Sencha
 
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
 
Android - Gradle build optimisation 3d83f31339d239abcc55f869e5f30348?s=47
Android - Gradle build optimisation  3d83f31339d239abcc55f869e5f30348?s=47Android - Gradle build optimisation  3d83f31339d239abcc55f869e5f30348?s=47
Android - Gradle build optimisation 3d83f31339d239abcc55f869e5f30348?s=47Bartosz Kosarzycki
 

Was ist angesagt? (20)

Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...
 
Tips and tricks for building Large web applications with Drupal
Tips and tricks for building Large web applications with DrupalTips and tricks for building Large web applications with Drupal
Tips and tricks for building Large web applications with Drupal
 
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 
Using and contributing to the next Guice
Using and contributing to the next GuiceUsing and contributing to the next Guice
Using and contributing to the next Guice
 
Play Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity StackPlay Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity Stack
 
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...
 
Introducing the (new) Google Docs API (2019)
Introducing the (new) Google Docs API (2019)Introducing the (new) Google Docs API (2019)
Introducing the (new) Google Docs API (2019)
 
Cloud Function For Firebase - GITS
Cloud Function For Firebase - GITSCloud Function For Firebase - GITS
Cloud Function For Firebase - GITS
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web Framework
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.x
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
Drupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systemsDrupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systems
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin Coroutines
 
Intro to sbt-web
Intro to sbt-webIntro to sbt-web
Intro to sbt-web
 
Introduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentIntroduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API Development
 
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
 
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
 
Android - Gradle build optimisation 3d83f31339d239abcc55f869e5f30348?s=47
Android - Gradle build optimisation  3d83f31339d239abcc55f869e5f30348?s=47Android - Gradle build optimisation  3d83f31339d239abcc55f869e5f30348?s=47
Android - Gradle build optimisation 3d83f31339d239abcc55f869e5f30348?s=47
 

Andere mochten auch

Using Google App Engine Python
Using Google App Engine PythonUsing Google App Engine Python
Using Google App Engine PythonAkshay Mathur
 
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
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version ControlWei-Tsung Su
 
Google Glass - Unit01: Design
Google Glass - Unit01: DesignGoogle Glass - Unit01: Design
Google Glass - Unit01: DesignWei-Tsung Su
 
Introduction to OAuth
Introduction to OAuthIntroduction to OAuth
Introduction to OAuthWei-Tsung Su
 
軟體系統測試簡介
軟體系統測試簡介軟體系統測試簡介
軟體系統測試簡介Wei-Tsung Su
 
Arduino Yun Mini - 使用SQLite
Arduino Yun Mini - 使用SQLiteArduino Yun Mini - 使用SQLite
Arduino Yun Mini - 使用SQLiteWei-Tsung Su
 
Google app engine python
Google app engine   pythonGoogle app engine   python
Google app engine pythonEueung Mulyana
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011Juan Gomez
 
App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munichdion
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con pythonsserrano44
 
App Engine for Python Developers
App Engine for Python DevelopersApp Engine for Python Developers
App Engine for Python DevelopersGareth Rushgrove
 
Arduino Yun Mini簡介
Arduino Yun Mini簡介Arduino Yun Mini簡介
Arduino Yun Mini簡介Wei-Tsung Su
 
LinkIt Smart 7688程式開發
LinkIt Smart 7688程式開發LinkIt Smart 7688程式開發
LinkIt Smart 7688程式開發Wei-Tsung Su
 
MQTT簡介與使用開放原始碼
MQTT簡介與使用開放原始碼MQTT簡介與使用開放原始碼
MQTT簡介與使用開放原始碼Wei-Tsung Su
 
Introduction to Wi-Fi Direct
Introduction to Wi-Fi DirectIntroduction to Wi-Fi Direct
Introduction to Wi-Fi DirectWei-Tsung Su
 
Introducing MQTT
Introducing MQTTIntroducing MQTT
Introducing MQTTAndy Piper
 
Introduction to NFC
Introduction to NFCIntroduction to NFC
Introduction to NFCWei-Tsung Su
 

Andere mochten auch (20)

Using Google App Engine Python
Using Google App Engine PythonUsing Google App Engine Python
Using Google App Engine Python
 
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
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
 
Google Glass - Unit01: Design
Google Glass - Unit01: DesignGoogle Glass - Unit01: Design
Google Glass - Unit01: Design
 
創業的藝術
創業的藝術創業的藝術
創業的藝術
 
Introduction to OAuth
Introduction to OAuthIntroduction to OAuth
Introduction to OAuth
 
軟體系統測試簡介
軟體系統測試簡介軟體系統測試簡介
軟體系統測試簡介
 
Arduino Yun Mini - 使用SQLite
Arduino Yun Mini - 使用SQLiteArduino Yun Mini - 使用SQLite
Arduino Yun Mini - 使用SQLite
 
Google app engine python
Google app engine   pythonGoogle app engine   python
Google app engine python
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011
 
App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munich
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con python
 
App Engine
App EngineApp Engine
App Engine
 
App Engine for Python Developers
App Engine for Python DevelopersApp Engine for Python Developers
App Engine for Python Developers
 
Arduino Yun Mini簡介
Arduino Yun Mini簡介Arduino Yun Mini簡介
Arduino Yun Mini簡介
 
LinkIt Smart 7688程式開發
LinkIt Smart 7688程式開發LinkIt Smart 7688程式開發
LinkIt Smart 7688程式開發
 
MQTT簡介與使用開放原始碼
MQTT簡介與使用開放原始碼MQTT簡介與使用開放原始碼
MQTT簡介與使用開放原始碼
 
Introduction to Wi-Fi Direct
Introduction to Wi-Fi DirectIntroduction to Wi-Fi Direct
Introduction to Wi-Fi Direct
 
Introducing MQTT
Introducing MQTTIntroducing MQTT
Introducing MQTT
 
Introduction to NFC
Introduction to NFCIntroduction to NFC
Introduction to NFC
 

Ähnlich wie Google App Engine for Python - Unit01: Basic

Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Pythonwesley chun
 
Infinite Scale - Introduction to Google App Engine
Infinite Scale - Introduction to Google App EngineInfinite Scale - Introduction to Google App Engine
Infinite Scale - Introduction to Google App EngineMarian Borca
 
File Repository on GAE
File Repository on GAEFile Repository on GAE
File Repository on GAElynneblue
 
Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)wesley chun
 
Accessing Google Cloud APIs
Accessing Google Cloud APIsAccessing Google Cloud APIs
Accessing Google Cloud APIswesley chun
 
Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)wesley chun
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App EngineFred Lin
 
Introduction to App Engine Development
Introduction to App Engine DevelopmentIntroduction to App Engine Development
Introduction to App Engine DevelopmentRon Reiter
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...wesley chun
 
Exploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overviewExploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overviewwesley chun
 
Google Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacksGoogle Cloud lightning talk @MHacks
Google Cloud lightning talk @MHackswesley chun
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP Eric Johnson
 
Simple stock market analysis
Simple stock market analysisSimple stock market analysis
Simple stock market analysislynneblue
 
Introduction to serverless computing on Google Cloud
Introduction to serverless computing on Google CloudIntroduction to serverless computing on Google Cloud
Introduction to serverless computing on Google Cloudwesley chun
 
App_Engine_PPT..........................
App_Engine_PPT..........................App_Engine_PPT..........................
App_Engine_PPT..........................HassamShahid2
 
appengine ja night #25 Google App Engine for PHP (English)
appengine ja night #25 Google App Engine for PHP (English)appengine ja night #25 Google App Engine for PHP (English)
appengine ja night #25 Google App Engine for PHP (English)Ryo Yamasaki
 

Ähnlich wie Google App Engine for Python - Unit01: Basic (20)

Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
 
Infinite Scale - Introduction to Google App Engine
Infinite Scale - Introduction to Google App EngineInfinite Scale - Introduction to Google App Engine
Infinite Scale - Introduction to Google App Engine
 
File Repository on GAE
File Repository on GAEFile Repository on GAE
File Repository on GAE
 
Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
Accessing Google Cloud APIs
Accessing Google Cloud APIsAccessing Google Cloud APIs
Accessing Google Cloud APIs
 
Django
DjangoDjango
Django
 
Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App Engine
 
Introduction to App Engine Development
Introduction to App Engine DevelopmentIntroduction to App Engine Development
Introduction to App Engine Development
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
 
Exploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overviewExploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overview
 
Google Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacksGoogle Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacks
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP
 
Simple stock market analysis
Simple stock market analysisSimple stock market analysis
Simple stock market analysis
 
Introduction to serverless computing on Google Cloud
Introduction to serverless computing on Google CloudIntroduction to serverless computing on Google Cloud
Introduction to serverless computing on Google Cloud
 
App_Engine_PPT.ppt
App_Engine_PPT.pptApp_Engine_PPT.ppt
App_Engine_PPT.ppt
 
App_Engine_PPT..........................
App_Engine_PPT..........................App_Engine_PPT..........................
App_Engine_PPT..........................
 
appengine ja night #25 Google App Engine for PHP (English)
appengine ja night #25 Google App Engine for PHP (English)appengine ja night #25 Google App Engine for PHP (English)
appengine ja night #25 Google App Engine for PHP (English)
 
App_Engine_PPT.ppt
App_Engine_PPT.pptApp_Engine_PPT.ppt
App_Engine_PPT.ppt
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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 educationjfdjdjcjdnsjd
 
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...Miguel Araújo
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 

Kürzlich hochgeladen (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
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...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Google App Engine for Python - Unit01: Basic

  • 1. Google App Engine (GAE) Wei-Tsung Su (蘇維宗) ellington.su@gmail.com 06/30/2014 (Ver. 1.0) Ubiquitous Computing and Ambient Networking Laboratory 1
  • 2. Change Log Date Ver. Authors Description 6/30/2014 1.0 Wei-Tsung Su Google App Engine (GAE); GAE for Python; Using Static Files; Google User Service Ubiquitous Computing and Ambient Networking Laboratory 2
  • 3. What? • Google Cloud Platform – App Engine provides Platform as a Service (PaaS) – Compute Engine provides Infrastrcture as a Servce (IaaS) – CloudSQL, Cloud Storage, and Cloud Datastore provide storage options – BigQuery and Hadoop provide big data processing capability • Language supported by GAE – Python, Java, PHP, and GO – Different languages may provide different features. Ubiquitous Computing and Ambient Networking Laboratory 3
  • 4. Why? • Easily deploy your web services to public • Seamlessly integrate with other Google services • Free quotas (https://developers.google.com/appengine/docs/quotas) – Code & Static Data Store (1GB free) – Google Cloud Storage (5GB free) – Blobstore Stored Data (5GB free) – API access (which depends on different Google API) – ... Ubiquitous Computing and Ambient Networking Laboratory 4
  • 5. How? • Read Support Documentation – https://developers.google.com/appengine/ • Try Administration Console – https://appengine.google.com/ – https://console.developers.google.com • Download SDK – https://developers.google.com/appengine/downloads Start Your Engine 3, 2, 1 Ubiquitous Computing and Ambient Networking Laboratory 5
  • 6. GAE for Python Ubiquitous Computing and Ambient Networking Laboratory 6
  • 7. Setup Development Environment • Install Python 2.7 – https://www.python.org/download/releases/2.7.7/ • Install App Engine SDK for Python – https://developers.google.com/appengine/downloads – Ex. we assume that google_appengine/ is the SDK directory. • Install Git (optional) – http://git-scm.com/downloads Ubiquitous Computing and Ambient Networking Laboratory 7
  • 8. How GAE for Python Works • A Python web app interacts with the App Engine web server using Web Server Gateway Interface (WSGI) protocol. • WSGI-compatible web application frameworks, such as – webapp2 (by default, simple) – Django – CherryPy – Pylons – web.py – web2py Ubiquitous Computing and Ambient Networking Laboratory 8
  • 9. Project Structure of GAE for Python • Modules – Dynamic web page generation – http://webapp-improved.appspot.com/ – Filename: xxx.py (ex. helloword.py) • Configuration File – Project configuration – Routing requests to modules – https://developers.google.com/appengine/docs/python/config/appconfig – Filename: app.yaml (壓謀!) • Ex. we assume that helloworld/ is the project directory Ubiquitous Computing and Ambient Networking Laboratory 9
  • 10. Module: helloworld. py • import webapp2 class MainPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/ html' self.response.write('Hello, World!') app = webapp2.WSGIApplication([ ('/', MainPage), ], debug=True) • For security issue, you should disable debug which will display a stack trace in the browser when a handler raises an exception. Ubiquitous Computing and Ambient Networking Laboratory 10
  • 11. Configuration File: app.yaml • application: your-app-id version: 1 runtime: python27 api_version: 1 threadsafe: true handlers: - url: /.* script: helloworld.app • How to test your project locally – # google_appengine/dev_appserver.py helloworld/ – Test your web app by visiting the URL: http://localhost:8080 Ubiquitous Computing and Ambient Networking Laboratory 11
  • 12. Hello, World! Ubiquitous Computing and Ambient Networking Laboratory 12
  • 13. Using Static Files • Sometimes, you may put static files, such images, CSS stylesheets, JavaScript code, and so on, into your web applications. • For example, – <img src="/images/logo.png" > • Unfortunately, you cannot just create a directory and put the static files into the directory. • You also need to add route into con figuration file: app.yaml – - url: /images static_dir: images Ubiquitous Computing and Ambient Networking Laboratory 13
  • 14. Google User Service • Google user service (https://developers.google.com/appengine/docs/python/users/) • Import user service module – from google.appengine.api import users • Get current user – user = users.get_current_user() # Google Account, Google Apps Account, OpenID • Access user information – user.nickname() – user.email() – user.user_id() • Administrator check – user.is_current_user_admin() • Create login/logout pages – users.create_login_url('[destination URL]') – users.create_logout_url('[destination URL]') Ubiquitous Computing and Ambient Networking Laboratory 14
  • 15. Google User Service - Example • from google.appengine.api import users import webapp2 class MainPage(webapp2.RequestHandler): def get(self): user = users.get_current_user() if user: self.response.headers['Content-Type'] = 'text/ html' self.response.write('Hello, World, %s!<br>', %(user.nickname())) self.response.write('<a href="%s">Sign Out</a>' % users.create_logout_url(self.request.url)) else: self.redirect(users.create_login_url(self.request.url) ) app = webapp2.WSGIApplication([ ('/', MainPage), ], debug=True) Ubiquitous Computing and Ambient Networking Laboratory 15
  • 16. Hello, World, User! Ubiquitous Computing and Ambient Networking Laboratory 16
  • 17. Deploy Your Application • Step 1: Create Project in Developer Console – https://console.developers.google.com – You will get a random project id (Ex. your-app-id). – The public URL of your web application will be • http://your-app-id.appspot.com • Step 2: Check if the application ID in app.yaml matches your-app-id – application: your-app-id • Step 3: Deploy your local project – #google_appengine/appcfg.py update helloworld/ – Test your web app by visiting the URL: http://your-app-id.appspot.com Ubiquitous Computing and Ambient Networking Laboratory 17
  • 18. Q&A You can clone the sample code by git clone https://github.com/ucanlab/gae_python_basic_helloworld.git or visiting https://github.com/ucanlab/gae_python_basic_helloworld Ubiquitous Computing and Ambient Networking Laboratory 18