SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

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
 

What's hot (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
 

Viewers also liked

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
 

Viewers also liked (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
 

Similar to 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
 

Similar to 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
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

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