gae静态目录html

时间:2012-06-11 03:19:39

标签: html google-app-engine

我正在尝试使用Google App Engine的app.yaml在请求时自动提供* .html文件。所以我的文件结构中有以下内容:

-myapp
    -html (folder)
        -index.html
    -index.py

在我的app.yaml中,我有:

handlers:
-url: /*\.html
static_dir: html

-url: /.*
script: index.app

但是,当我在我的浏览器localhost:8080 / index.html上运行时,我得到404 Not Found。 为什么不路由到我的index.html文件?

1 个答案:

答案 0 :(得分:2)

根据你想要的东西,有几种方法可以做这种事情。如果你想要的只是静态内容而没有任何更高级的功能,你可以使用@hyperslug这样的正则表达式添加。

您可以像这样设置网址:

- url: /
  static_files: static/html/index.html
  upload: static/html/index.html
  secure: never

允许您根据个人文件设置页面安全性,如果这是您想要的。或者您可以将正则表达式与安全性结合起来,例如:

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

请记住,如果您与公共搜索引擎共享页面,则将http / https视为2个不同的链接。以及有和没有尾随/.

相关问题