your first program always "Hello world!"
*******
學什麼程式語言,第一個程式幾乎都是Hello World!
一個用來表現「輸出」的意義的簡單程式
學習,App Engine也不例外
也許不用知道怎麼寫程式,但是至少要知道怎麼佈署(Deploy)
當你拿到原始碼,只要更動少部分的參數,就能運作正常
筆者用Mac版本的GoogleAppEngineLauncher示範
一個App Engine程式的發佈
Google App Engine網站有提供三大平台的GUI Tool
Windows、Mac OS、Linux

Mac版的安裝,就跟平常的軟體安裝沒兩樣
拖曳到應用程式資料夾,第一次執行時會被詢問是否要與系統連結
大致上就是建立ENV,輸入密碼就好
不困難的安裝方式

進入主程式,方常簡單的介面

沒有幾個按鈕,這只是發佈工具
連Text Editor的規模都沒有,更別提IDE了
請按一下左下方的+
會出現小視窗,請輸入應用程式的名稱
就是之前網頁介面設定時的Application Identifier
並指定存放程式原始檔的路徑
Port的部份建議就不用動了,讓Launcher自行處理
按下Create鈕吧!

指定的資料夾會建立檔案
資料夾名稱就是應用程式名
裡面有app.yaml、index.yaml與main.py

app.yaml主要描述程式的名稱(application)
版本(version與api_version,之後用來版本控制用的)
還有者程式與url路徑
執行的程式就是python(希望未來有Ruby...)

index.yaml,顧名思義是索引用途
大概是用在資料庫的操作
Google自己有自家的GQL

main.py即主程式
GoogleAppEngineLauncher預設是產生輸出hello world的主程式
你可以由這個簡單的程式初步了解python的運作哲學

基本上這裡不用你改任何程式,只要告訴你Hello World
按下Run的鈕開始編譯
可以看Log了解編譯進度

編譯完成後,再按Browse的鈕
執行瀏覽器,你就看到Hello World了

SDK Console的鈕可以用瀏覽器監看資源的使用
與簡單的輸出模擬功能

按下Deploy,出現Google帳號登入驗證
這次真的要把程式丟到Google伺服器了

還是可以參考Log得知Deploy進度

看看網址,真的佈署成功了

這次就先介紹到這,下次試驗怎麼改Sample Code的應用
再丟上去變成自己的Application
*******
應用程式的佈署完成後
Dashboard就出現監看項目
大家可以自己去玩玩看
這篇文章雖然沒有什麼深度
但是相信能讓你有碰到雲端運算的邊之感
繼續努力吧!
沒有留言:
張貼留言