網路科技

Google App Engine (3) : Python

商業,創業,業務,職涯,美食,葡萄酒,閱讀,網路科技。

從 Larry 創業以及商業的經驗,希望以白話的口吻,介紹給大家這個商業的世界。

FB粉專會頻繁地更新 Larry 對於商業、社會、人生的觀察與心得,歡迎大家追蹤互動~

嘗試分析一下這個 GAE 基礎 sample 的架構
https://github.com/GoogleCloudPlatform/appengine-guestbook-python

他是教學網頁(大概是從這一頁開始)
https://developers.google.com/appengine/docs/python/gettingstartedpython27/handlingforms
的範例程式碼.

首先看 app.yaml. 其中

- url: /.*
  script: guestbook.application

說明會有一個 “guestbook” module (guestbook.py), 裡面會有一個 “application” object 當作 request handler.

另外 app.yaml 中

libraries:
- name: webapp2
  version: latest
- name: jinja2
  version: latest

指出這個 application 中使用 webapp2, jinja2 兩個 library (jinja2 是 templating engine). 使用 jinja2 可以將一大堆 html 從 guestbook.py 中切開 (此例是放在 index.html, 使用了 bootstrap front-end framework).

Python NDB 的部分主要是用在 request handling module (guestbook.py). By
https://developers.google.com/appengine/docs/python/gettingstartedpython27/usingdatastore
為了要有效率的 query data, Google Datastore 建議要用 custom index for some queries, 在此例中, 宣告在 index.yaml. Datastore 的部分我覺得是比較艱澀難懂, 留在之後再研究.

商業,創業,業務,職涯,美食,葡萄酒,閱讀,網路科技。

從 Larry 創業以及商業的經驗,希望以白話的口吻,介紹給大家這個商業的世界。

FB粉專會頻繁地更新 Larry 對於商業、社會、人生的觀察與心得,歡迎大家追蹤互動~