close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": /usr/lib/python2.7/dist-packages/libsvn/_repos.so: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.
- Timestamp:
-
Nov 11, 2008, 4:21:50 PM (17 years ago)
- Author:
-
zsjheng
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v1
|
v2
|
|
| 1 | .......未完待續先存檔........ |
| 2 | |
| 3 | |
1 | 4 | '''3. 開發Google App Engine程式''' |
2 | 5 | |
| 6 | 本章節將要開始進入實際編寫Google App Engine專案的階段。 為了讓讀者對於整個開發過程更有感覺,本章節將會開發一個精簡但完整的便當訂購系統來取代零星的小範例程式。 首先3.1節會介紹一個可運作的Google App Engine專案需要哪些內容,雖然在第一章的Hello Wolrd程式已經有稍微說明,本章會更詳細地說明一些細節以及額外的應用;3.2節則將介紹一般在開發較大型的Web應用程式時經常應用的樣板技術如何在Google App Engine平台來實作;在3.3節說明了 |
3 | 7 | |
4 | 8 | '''3.1 Google App Engine專案基本元件''' |
5 | 9 | |
| 10 | |
| 11 | * Main Page |
| 12 | |
| 13 | |
| 14 | * app.yaml |
| 15 | |
| 16 | Google App Engine為Google所提供的Web應用程式平台,網頁為其提供服務的主要溝通介面。 一般常見的Web平台 (Apache、IIS等) 只要將網頁專案上傳到Web伺服器上的空間,一旦server端接收到來自client端的request,Web server會自動尋找根目錄下的預設首頁 (例如Apache平台常使用的index.htm/html以及IIS平台常用之default.htm/html) 並執行後response給client端由client端的瀏覽器來解析網頁內容;這些預設值皆可以透過修改伺服器本身的設定檔來作修改 (例如Apache Web server的設定檔 httpd.conf)。 此外,一般Web server也會以所request的URL對應Web應用程式根目錄的命名空間來存取所request的檔案。 |
| 17 | |
| 18 | 在Google App Engine平台並未限定使用者的Web應用程式需要使用任何限定名稱的檔案來作為首頁,這完全由使用者依照自己的喜好來自行設定,這也就是app.yaml的主要功能-設定應用程式專案中,應用程式檔案的命名空間 |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | {{{ |
| 24 | application: myapp |
| 25 | version: 1 |
| 26 | runtime: python |
| 27 | api_version: 1 |
| 28 | |
| 29 | handlers: |
| 30 | - url: / |
| 31 | script: home.py |
| 32 | |
| 33 | - url: /index\.html |
| 34 | script: home.py |
| 35 | |
| 36 | - url: /stylesheets |
| 37 | static_dir: stylesheets |
| 38 | |
| 39 | - url: /(.*\.(gif|png|jpg)) |
| 40 | static_files: static/\1 |
| 41 | upload: static/(.*\.(gif|png|jpg)) |
| 42 | |
| 43 | - url: /admin/.* |
| 44 | script: admin.py |
| 45 | login: admin |
| 46 | |
| 47 | - url: /.* |
| 48 | script: not_found.py |
| 49 | }}} |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | '''3.2 使用樣板功能(template)''' |
| 55 | |
| 56 | |
| 57 | |
| 58 | '''3.3 ''' |