2012-06-06 59 views

回答

1

我真的不認爲這是谷歌有意使用該服務。但如果你真的需要需要來提供一些簡單的靜態內容。

您定義app.yaml文件,像這樣:

application: staticapp 
version: 1 
runtime: python27 
api_version: 1 
threadsafe: true 

handlers: 
- url:/
    static_files: index.html 
    upload: index.html 

- url: /index.css 
    static_files: index.css 
    upload: index.css 

-url: /index.js 
    static_files: index.js 
    upload: index.js 

然後使用appcfg update .(源目錄假設你使用Linux)

+0

謝謝。我正在使用Windows GAE啓動器。但是,我現在在部署時出現此錯誤:AppInfoExternal類型的對象的意外屬性'-url'。 – Ognjen

+0

您必須等待Windows用戶在那裏幫忙。這適用於Linux,注意我更新了我的答案,因爲我需要添加threadsafe和api_version。 我嘗試使用Windows啓動一次,並不能得到它的工作,而它是在Linux上死的簡單。 *尼克斯真的是最好的網站開發海事組織。你 還需要增加一個行,如果你的應用程序需要這些服務的圖像。讓我知道我可以添加它。 –

+0

@Ognjen我剛剛注意到你的錯誤。你有'--url'你應該有' - url'注意這個空間。 –

4

你並不需要在應用程序單獨叫出每個文件。正如Mark所建議的那樣;相反,像這樣的簡單處理就足夠了:

application: myapp 
version: main 
runtime: python27 
api_version: 1 
threadsafe: true 

handlers: 
- url: /(.*)/ 
    static_files: \1/index.html 
    upload: .*/index.html 
- url: /.* 
    static_dir: static 

然後把你的網站在一個名爲包含app.yaml目錄下的「靜態」的目錄。

第一處理器保證index.html送達的任何時候有人問一個目錄。第二個處理程序直接從靜態目錄提供所有其他URL。

+0

尼克,你會介意坐看看這個[問題](http://stackoverflow.com/questions/10906696/app-engine-not-recognizing-logged-in-user-with-users-service),而你的工作改進我的代碼? ;-) –

0

我做了一個簡單的圍棋程序,這是否非常漂亮。 http://yourdomain.com將成爲了index.html,然後在頁面的其餘部分是在http://yourdomain.com/mypage.html

這裏訪問是在YAML:

application: myawesomeapp 
version: 1 
runtime: go 
api_version: go1 

handlers: 
- url: /.* 
    script: _go_app 

這裏的圍棋程序,將有助於你的所有靜態文件在根級別:

package hello 

import (
    "net/http" 
) 

func init() { 
    http.HandleFunc("/", handler) 
} 

func handler(w http.ResponseWriter, r *http.Request) { 
    http.ServeFile(w, r, "static/"+r.URL.Path) 
} 

然後將所有靜態文件放在/靜態目錄中,運行goapp deploy並完成。

相關問題