如何通过app yaml服务一个静态文件

时间:2014-12-22 23:43:31

标签: python 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

感谢您的帮助

1 个答案:

答案 0 :(得分: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)$

上传部分代表文件路径,而不是网址。

docs中的

表示此配置等同于

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

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