【问题标题】:google app engine yaml index.html谷歌应用引擎 yaml index.html
【发布时间】:2012-09-02 02:44:55
【问题描述】:

我希望任何以“/”结尾的 url 的获取请求,例如 http://website.com/some_dir/,以接收该目录中的 index.html 文件...在我的示例中,它应该接收 http://website.com/some_dir/index.html。

我让它在本地与 GAE 启动器/本地服务器一起工作......但是当我部署它并通过 website.appspot.com 访问它时它失败了...... 我得到错误:

错误:未找到

在此服务器上找不到请求的 URL /some_dir/。

这是我的 yaml 中的内容:

- url: /
  static_files: staticLocation/index.html
  upload: staticLocation/index.html
- url: (.+)/
  static_files: staticLocation/\1/index.html
  upload: staticLocation
- url: /
  static_dir: staticLocation

我很好奇它如何/为什么在本地运行良好,但在 apppot 上却没有...... 想法,以及如何解决我的问题?

【问题讨论】:

    标签: python google-app-engine


    【解决方案1】:

    您的第二条路线的“上传”行不够详细,因此其中的文件不会部署到 appengine。你想要这样的东西:

    - url: (.+)/
      static_files: staticLocation/\1/index.html
      upload: staticLocation/(.*)
    
    - url: /(.+)
      static_files: staticLocation/\1/index.html
      upload: staticLocation/(.+)/index.html
    

    (您的最后一条路线与第一条路线具有相同的 url,因此它永远不会被击中并且可以被删除。)

    【讨论】:

      【解决方案2】:

      我已确认您的问题。在本地工作,但不在 apppot 上工作。要解决您的问题更改:

      - url: (.+)/
        static_files: staticLocation/\1/index.html
      

      到

      - url: (.*)/
        static_files: staticLocation\1/index.html`
      

      它应该可以正常工作。 (注意:+ 在url 中更改为*,/ 在static_files 中被删除)

      为了满足您的好奇心,您匹配了领先的/,因此文件系统位置查找是staticlocation//some_dir/index.html,它在您的文件系统上运行良好,因为// 在您的操作系统中折叠为仅/。我认为 apppot 的路径查找不会折叠 //,这会导致找不到您的 index.html 文件。

      哦,顺便说一句,像我提到的那样修复第二条规则将使您根本不需要第一条规则,因此可以删除该规则。

      【讨论】:

        【解决方案3】:

        AppEngine 生产服务器是区分大小写的文件系统,请检查两个大小写是否匹配。

        【讨论】:

          猜你喜欢
          • 2012-11-10
          • 2016-07-14
          • 2011-05-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-12-12
          相关资源
          最近更新 更多