2014-12-22 33 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/.*