2011-07-20 97 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

你說得對。 –