SlideShare a Scribd company logo
1 of 33
 
Google App Engine  快速入门 2008 年 10 月 24 日
日程 ,[object Object],[object Object],[object Object],[object Object]
基本概念
创建一个  Web  应用,往往需要自己干很多体力活…
Google  提供的成套解决方案
开箱即用 ,  易上手
应用详例
我们要开发 : ,[object Object],[object Object],http:// tag080808 .appspot.com
0.  注册 App Engine ,[object Object],[object Object]
1.  app.yaml   配置文件 application:  tag080808 version:  2 runtime:  python api_version:  1 handlers: - url:  /static static_dir:  static - url:  /admin.* script:  admin.py login:  admin - url:  /.* script:  main.py
from  google.appengine.ext  import  db class   Tweet (db. Model ): text = db. StringProperty () id = db. IntegerProperty () from_user = db. StringProperty () created_at = db. DateTimeProperty () iso_language_code = db. StringProperty () profile_image_url = db. LinkProperty () class   User (db. Model ): name = db. StringProperty () screen_name = db. StringProperty () followers_count = db. IntegerProperty () count = db. IntegerProperty () id = db. IntegerProperty () description = db. StringProperty () ... 2. Data Model
3.  后台抓取数据 class  FetchHandler(webapp.RequestHandler): def  get(self): url =( "http://search.twitter.com/search.json?q=%%23080808" "&page=%d"  % page) response = urlfetch.fetch(url) if  response.status_code ==  200 : data = simplejson.loads(response.content) results = data[ "results" ] for  result in results tweet = datamodel.Tweet( id = result[ "id" ], from_user = result[ "from_user" ], text = result[ "text" ], created_at = parse_time(result[ "created_at" ]) ) tweet.put() ......
class DefaultPage(webapp.RequestHandler): def get(self): top_users =  datamodel.User.gql("ORDER BY count DESC LIMIT 20") template_values = {"top_users":  to p_users} path = os.path.join(os.path.dirname(__file__),    "templates/default.html") self.response.headers["Content-Type"] =    "text/html" self.response.out.write(template.render(path, template_values))  4 .  排行榜显示页面
class DefaultPage(webapp.RequestHandler): def get(self): top_users =  datamodel.User.gql("ORDER BY count DESC LIMIT 20") template_values = { "top_users": top_users } path = os.path.join(os.path.dirname(__file__), "templates/default.html") self.response.headers["Content-Type"] = "text/html" self.response.out.write(template.render(path, template_values))  4 .  排行榜显示页面
class DefaultPage(webapp.RequestHandler): def get(self): if memcache.get("top_users") is None: top_users =  datamodel.User.gql("ORDER BY count DESC LIMIT 20") memcache.set("top_users", simplejson.dumps(top_users)) else:  top_users = memcache.get("top_users") template_values = { "top_users": top_users } path = os.path.join(os.path.dirname(__file__), "templates/default.html") self.response.headers["Content-Type"] = "text/html" self.response.out.write(template.render(path, template_values))  4 .  排行榜显示页面
<!DOCTYPE html> <html> ... <body> ... {% for user in top_users %} <dl> <dt><a href=“/tweeter/{{ user.user }}”>{{ user.name }}</a></dt> < dd >{{user.count }}</dd> </dl> {% endfor %} ... </body> 5. HTML  模板  default.html
6.  开发调试环境
7.  部署! appcfg.py update  application_folder
http:// tag080808 .appspot.com 或者使用自己的域名 ! http:// me.tag080808.com
8.  监测自己的应用
其它 APIs
Memcache API 为常用页面和数据库查询加速 Mail API 自动发送邮件 URL Fetch API 抓取其他互联网资源 Users API 与  Google  账户轻易整合 Images API 基本图片处理
zhen-gong-fu.appspot.com code.google.com/p/zhen-gong-fu
其它应用与展望未来
和  Google Apps  的整合 Map.yuanpei.org
Google App Engine + OpenSocial TBD:  Focus on  是男人系列 http://code.google.com/apis/opensocial/ articles/appengine-0.8.html
Google App Engine + OpenSocial TBD:  Focus on  是男人系列
PREVIEW
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
教程、文档、资源、精品文章… http://code.google.com/appengine 作品展示… http://appgallery.appspot.com/ 示例代码下载… http://code.google.com/p/google-app-engine-samples/
谢谢 !

More Related Content

Similar to Google App Engine Devfest 200810 External

揭秘Html5和Css3
揭秘Html5和Css3揭秘Html5和Css3
揭秘Html5和Css3Adam Lu
 
揭秘Html5和Css3 ---- 鲁超伍
揭秘Html5和Css3 ---- 鲁超伍揭秘Html5和Css3 ---- 鲁超伍
揭秘Html5和Css3 ---- 鲁超伍裕波 周
 
Html5css3 go.yeefe.com
Html5css3 go.yeefe.comHtml5css3 go.yeefe.com
Html5css3 go.yeefe.comtellyeefe
 
Asp.net mvc 培训
Asp.net mvc 培训Asp.net mvc 培训
Asp.net mvc 培训lotusprince
 
Chicago EXPO Creating a Pure CSS Template in Joomla 1.5
Chicago EXPO Creating a Pure CSS Template in Joomla 1.5Chicago EXPO Creating a Pure CSS Template in Joomla 1.5
Chicago EXPO Creating a Pure CSS Template in Joomla 1.5compassdesign
 
HTML5概览
HTML5概览HTML5概览
HTML5概览Adam Lu
 
Struts1+ hibernate3
Struts1+ hibernate3Struts1+ hibernate3
Struts1+ hibernate3edanwade
 
YUI ─ 阿大
YUI ─ 阿大YUI ─ 阿大
YUI ─ 阿大taobao.com
 
Denver CMS Expo Creating CSS template
Denver CMS Expo Creating CSS templateDenver CMS Expo Creating CSS template
Denver CMS Expo Creating CSS templatecompassdesign
 
Creating CSS Template with Barrie North
Creating CSS Template with Barrie NorthCreating CSS Template with Barrie North
Creating CSS Template with Barrie NorthJohn Coonen
 
Django
DjangoDjango
DjangoTao He
 
Django Firstofhexu
Django FirstofhexuDjango Firstofhexu
Django Firstofhexuhexuotzo
 
Django讲座
Django讲座Django讲座
Django讲座Qing Feng
 
TBAD F2E 2010 review
TBAD F2E 2010 reviewTBAD F2E 2010 review
TBAD F2E 2010 reviewleneli
 
旺铺前端设计和实现
旺铺前端设计和实现旺铺前端设计和实现
旺铺前端设计和实现hua qiu
 
Anroid development part.1
Anroid development part.1Anroid development part.1
Anroid development part.1RANK LIU
 
Intro to Google Gadgets
Intro to Google GadgetsIntro to Google Gadgets
Intro to Google GadgetsYenwen Feng
 
Windows Mobile Widget 開發
Windows Mobile Widget 開發Windows Mobile Widget 開發
Windows Mobile Widget 開發Chui-Wen Chiu
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)Wei Sun
 

Similar to Google App Engine Devfest 200810 External (20)

揭秘Html5和Css3
揭秘Html5和Css3揭秘Html5和Css3
揭秘Html5和Css3
 
揭秘Html5和Css3 ---- 鲁超伍
揭秘Html5和Css3 ---- 鲁超伍揭秘Html5和Css3 ---- 鲁超伍
揭秘Html5和Css3 ---- 鲁超伍
 
Html5css3 go.yeefe.com
Html5css3 go.yeefe.comHtml5css3 go.yeefe.com
Html5css3 go.yeefe.com
 
Asp.net mvc 培训
Asp.net mvc 培训Asp.net mvc 培训
Asp.net mvc 培训
 
Chicago EXPO Creating a Pure CSS Template in Joomla 1.5
Chicago EXPO Creating a Pure CSS Template in Joomla 1.5Chicago EXPO Creating a Pure CSS Template in Joomla 1.5
Chicago EXPO Creating a Pure CSS Template in Joomla 1.5
 
HTML5概览
HTML5概览HTML5概览
HTML5概览
 
Struts1+ hibernate3
Struts1+ hibernate3Struts1+ hibernate3
Struts1+ hibernate3
 
YUI ─ 阿大
YUI ─ 阿大YUI ─ 阿大
YUI ─ 阿大
 
Denver CMS Expo Creating CSS template
Denver CMS Expo Creating CSS templateDenver CMS Expo Creating CSS template
Denver CMS Expo Creating CSS template
 
Creating CSS Template with Barrie North
Creating CSS Template with Barrie NorthCreating CSS Template with Barrie North
Creating CSS Template with Barrie North
 
Web base 吴志华
Web base 吴志华Web base 吴志华
Web base 吴志华
 
Django
DjangoDjango
Django
 
Django Firstofhexu
Django FirstofhexuDjango Firstofhexu
Django Firstofhexu
 
Django讲座
Django讲座Django讲座
Django讲座
 
TBAD F2E 2010 review
TBAD F2E 2010 reviewTBAD F2E 2010 review
TBAD F2E 2010 review
 
旺铺前端设计和实现
旺铺前端设计和实现旺铺前端设计和实现
旺铺前端设计和实现
 
Anroid development part.1
Anroid development part.1Anroid development part.1
Anroid development part.1
 
Intro to Google Gadgets
Intro to Google GadgetsIntro to Google Gadgets
Intro to Google Gadgets
 
Windows Mobile Widget 開發
Windows Mobile Widget 開發Windows Mobile Widget 開發
Windows Mobile Widget 開發
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)
 

Google App Engine Devfest 200810 External

  • 1.  
  • 2. Google App Engine 快速入门 2008 年 10 月 24 日
  • 3.
  • 5. 创建一个 Web 应用,往往需要自己干很多体力活…
  • 7. 开箱即用 , 易上手
  • 9.
  • 10.
  • 11. 1. app.yaml 配置文件 application: tag080808 version: 2 runtime: python api_version: 1 handlers: - url: /static static_dir: static - url: /admin.* script: admin.py login: admin - url: /.* script: main.py
  • 12. from google.appengine.ext import db class Tweet (db. Model ): text = db. StringProperty () id = db. IntegerProperty () from_user = db. StringProperty () created_at = db. DateTimeProperty () iso_language_code = db. StringProperty () profile_image_url = db. LinkProperty () class User (db. Model ): name = db. StringProperty () screen_name = db. StringProperty () followers_count = db. IntegerProperty () count = db. IntegerProperty () id = db. IntegerProperty () description = db. StringProperty () ... 2. Data Model
  • 13. 3. 后台抓取数据 class FetchHandler(webapp.RequestHandler): def get(self): url =( &quot;http://search.twitter.com/search.json?q=%%23080808&quot; &quot;&page=%d&quot; % page) response = urlfetch.fetch(url) if response.status_code == 200 : data = simplejson.loads(response.content) results = data[ &quot;results&quot; ] for result in results tweet = datamodel.Tweet( id = result[ &quot;id&quot; ], from_user = result[ &quot;from_user&quot; ], text = result[ &quot;text&quot; ], created_at = parse_time(result[ &quot;created_at&quot; ]) ) tweet.put() ......
  • 14. class DefaultPage(webapp.RequestHandler): def get(self): top_users = datamodel.User.gql(&quot;ORDER BY count DESC LIMIT 20&quot;) template_values = {&quot;top_users&quot;: to p_users} path = os.path.join(os.path.dirname(__file__), &quot;templates/default.html&quot;) self.response.headers[&quot;Content-Type&quot;] = &quot;text/html&quot; self.response.out.write(template.render(path, template_values)) 4 . 排行榜显示页面
  • 15. class DefaultPage(webapp.RequestHandler): def get(self): top_users = datamodel.User.gql(&quot;ORDER BY count DESC LIMIT 20&quot;) template_values = { &quot;top_users&quot;: top_users } path = os.path.join(os.path.dirname(__file__), &quot;templates/default.html&quot;) self.response.headers[&quot;Content-Type&quot;] = &quot;text/html&quot; self.response.out.write(template.render(path, template_values)) 4 . 排行榜显示页面
  • 16. class DefaultPage(webapp.RequestHandler): def get(self): if memcache.get(&quot;top_users&quot;) is None: top_users = datamodel.User.gql(&quot;ORDER BY count DESC LIMIT 20&quot;) memcache.set(&quot;top_users&quot;, simplejson.dumps(top_users)) else: top_users = memcache.get(&quot;top_users&quot;) template_values = { &quot;top_users&quot;: top_users } path = os.path.join(os.path.dirname(__file__), &quot;templates/default.html&quot;) self.response.headers[&quot;Content-Type&quot;] = &quot;text/html&quot; self.response.out.write(template.render(path, template_values)) 4 . 排行榜显示页面
  • 17. <!DOCTYPE html> <html> ... <body> ... {% for user in top_users %} <dl> <dt><a href=“/tweeter/{{ user.user }}”>{{ user.name }}</a></dt> < dd >{{user.count }}</dd> </dl> {% endfor %} ... </body> 5. HTML 模板 default.html
  • 19. 7. 部署! appcfg.py update application_folder
  • 20. http:// tag080808 .appspot.com 或者使用自己的域名 ! http:// me.tag080808.com
  • 23. Memcache API 为常用页面和数据库查询加速 Mail API 自动发送邮件 URL Fetch API 抓取其他互联网资源 Users API 与 Google 账户轻易整合 Images API 基本图片处理
  • 26. 和 Google Apps 的整合 Map.yuanpei.org
  • 27. Google App Engine + OpenSocial TBD: Focus on 是男人系列 http://code.google.com/apis/opensocial/ articles/appengine-0.8.html
  • 28. Google App Engine + OpenSocial TBD: Focus on 是男人系列
  • 30.
  • 31.
  • 32. 教程、文档、资源、精品文章… http://code.google.com/appengine 作品展示… http://appgallery.appspot.com/ 示例代码下载… http://code.google.com/p/google-app-engine-samples/