2011-07-20 127 views
0

的目录结构是 -无法读取根html(/index.html)。返回404

MyApplication (Project Dir) 

-static 
    --inside static, I got different dirs containing images, css, htmls, etc 
-some other dirs 
-app.yaml 
-index.py 
-index.html 

的app.yaml是 -的内容

application: MyApplicationID 
version: 1 
runtime: python 
api_version: 1 

handlers: 

- url: /favicon.ico 
    static_files: static/images/favicon.ico 
    upload: static/images/favicon.ico 
    mime_type: image/x-icon 

- url: /robots.txt 
    static_files: static/robots.txt 
    upload: static/robots.txt 

- url: /static 
    static_dir: static 
    secure: optional 

- url: /projects 
    static_dir: projects 
    secure: optional 

- url: /about 
    static_dir: about 
    secure: optional 

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

- url: /.* 
    script: index.py 
    secure: optional 

一切正常,只是如果在html页面的任何重定向到“ index.html“让我找不到页面(”GET /index.html HTTP/1.1“404 -)错误。我试过这个 - https://gist.github.com/873098但仍然没有运气。我尝试了其他线程的其他建议,但仍然没有运气。如果我删除- url:/仍然没有运气。请指教。

回答

1

的其他人是对的,你不必为网址index.html一个条目,像

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

编辑2:只要是明确的,没有不管static_files行是什么,这仍然会导致URL为http://mysite.com/index.html,即使static_files行包含一个子目录。

+0

没有工作,我不想有像http://myURL.com/some_dir/index.html –

+0

dir你是误会!您的计算机上的目录与用于检索它的目录无关。这就是' - url:'行的设置。 – agf

+0

谢谢。意思是说。 :) –

1

对于“/index.html”的请求将由index.py处理,给定app.yaml的内容。据推测,你没有在该文件中的“/index.html”处理程序。

如果您希望为“/index.html”的请求提供index.html,请添加一个与app.yaml匹配的映射(或者,重定向到“/”而不是“/index.html”)在现场,这是不太难看)

+0

我愿意。 def render(self,template_file,template_value): path = os.path.join(os.path.dirname(__ file __),template_file) self.response.out.write(template.render(path,template_value)) –

+0

def get(self): self.render('index.html',{}) –

+0

你说得对。 –