安裝Google Applicaiton Engine(GAE)開發環境

Install the development environment of Google Applicaiton Engine (GAE)

1. Install Python
2. Install GoogleAppEngine-1.5.4.msi (Download from http://code.google.com/intl/zh-TW/appengine/downloads.html)
3. Install eclipse for java Developer (maybe install the jre-7-windows-x64.exe)
4. Run eclipse.exe
– Help/Install New Software
– Click Available Software Sites link
– Input
Name: PyDev
Location: http://pydev.org/updates

or

Name: PyDev
URL: http://pydev.sourceforge.net/updates/

– Click ok
– Previous Dialog now has PyDev item, select it and press “ok” (至少安裝 PyDev for Eclipse)
– Select ALL and Press “Next” to install
– Press “Next” in Install Details page
– Click “I accept…” radio box and “Finish” button
– 裝好後要先設定一下 Python 的執行路徑,在功能表中選擇 Preferences…
(Windows 版的 Eclipse 應該是放在 Window > Preference 下) ,
然後打開左側的 PyDev > Interpreter – Python,再按下右上角的 New…
選擇 pythonw 的位置,然後 Eclipse 就會幫你設好一些 Python 預設使用
的路徑,直接確定即可。
– File / New / Project… > PyDev Project
Name: zhupiter_prj1
Version: 2.7
然後就可以開始來建立一個 GAE 的專案了,在 New Project… 的部份選擇
Pydev > Pydev Project,按下 Next 後,輸入專案名稱,project type
選擇 python 2.5,然後記住把「create default ‘src’ ..」這個部份取消打勾後
按下 Finish。
– Select the project and press right muse key, select “Properties”
Resource > Text file encoding: UTF-8
PyDev – PYTHONPATH > Add source folder (if not set)
接下來,在左側的專案視窗中,專案根目錄上按右鍵選 Properties,
然後選擇 PyDev – PYTHONPATH 然後在 Add source folder 中加入專案的
根目錄及 appengine 目錄。
– Select the project and press right muse key, select New > File
Name: app.yaml
, Press Finish
———————-
application: zhupiter_prj1
version: 1
runtime: python
api_version: 1

handlers:
– url: /
script: main.py
———————-

– Select the project and press right muse key, select New > PyDev Module
Source Folder: /zhupiter_prj1
Name: main
, Press Finish
———————-
print ‘Content-Type:text/plain’
print ”
print ‘My test’
———————-

– Select the project and press right muse key, select New > Folder
Folder name: appeninge
Advanced: “Link to alternate…” : C:\Program Files (x86)\Google\google_appengine
, Press Finish
接著,在專案目錄上按右鍵選擇 New > Folder,然後輸入 appengine,
打開 Advanced,勾選「Link to folder in the file system」,
然後選擇 GAE 的安裝目錄。

– Select the project and press right muse key, select Run As\Run Configure
Select Python Run
Project: zhupiter_prj1
Main Module: main.py

Select “Argument” tag
Working directory: Other > Workspace > zhupiter_prj1
, Press “Run”

然後你就可以在此目錄下開始開發 GAE 的程式了

現在要啟動 GAE 提供的 app server 來測試,用 IDE 就是希望能直接按個 Run 就能啟動來測試了,所以現在就在專案根目錄按下右鍵選擇 Run As ? Open Run Dialog…,然後在 Python Run 點兩下建立一個新的配置。

Name 可以打專案名稱,Project 選擇你的專案,注意 Main Module 的地方要選擇 appengine/dev_appserver.py,因為這是要執行的 script。

然後再切到 Arguments 這個 tab,在 Program arguments 中打一個「.」(代表目前這個目錄),然後 Working directory 最好也設定一下到這個專案的根目錄
都設定好之後就可以按 Apply 結束。

這樣一來,你只要在這個專案下按 Run,就會啟動 GAE 的 app server 了

– Open “Google App Engine Launcher” : C:\Program Files (x86)\Google\google_appengine\appengine_launcher.bat
Select “Add Exiting Applicaiton…”
Applicaiton Path: d:\work\workspace\zhupiter_prj1
Port: 8080
Press “Run”

– Open Browser
type: http://localhost:8080
U can see the result on browser.

– 發佈

Reference:
. http://www.scribd.com/doc/35546742/%E9%9B%B2%E7%AB%AF%E9%81%8B%E7%AE%97-Google-App-Engine-GAE-%E7%A8%8B%E5%BC%8F%E9%96%8B%E7%99%BC%E5%85%A5%E9%96%80-for-Python

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.