2014-12-22 36 views
0

我嘗試以下,但它給了一個錯誤如何服務器一個靜態文件,通過應用YAML

- url: /path/mypage.html 
    static_files: static/path/mypage.html 

我也試過

- url: /path/mypage.html 
    static_files: static/path/mypage 

錯誤說Missing "upload" attribute for URL "/path/mypage.html"

然後我試圖加入upload仍然會出錯

- url: /path/mypage.html 
    static_files: static/path/mypage 
    upload: /path/mypage.html 

    - url: /path/mypage.html 
    static_files: static/path/mypage.html 
    upload: /path/mypage.html 

感謝所有幫助

回答

0

,如果你只希望提供靜態文件,你可以使用static_dir標籤

- url: /stylesheets  <-- the url subdirectory 
static_dir: stylesheets <-- folder with the static files 

- url: /(.*\.(gif|png|jpg))$ 
static_files: static/\1 
upload: static/.*\.(gif|png|jpg)$ 

上傳部分代表文件路徑,而不是URL。

docs

說,這種配置是相當的

handlers: 
    - url: /images 
    static_dir: static/images 

    - url: /images/(.*) 
    static_files: static/images/\1 
    upload: static/images/.*