2012-06-06 57 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并完成。

相关问题