【问题标题】:Google app engine 100 URLMap entries limitationGoogle 应用引擎 100 个 URLMap 条目限制
【发布时间】:2012-07-03 03:30:53
【问题描述】:

我一直在使用谷歌应用引擎构建我的网站,遇到了关于 URLMap 最大数量的问题(我有 101 个 URL,但限制是 100)。这是错误消息:

Fatal error when loading application configuration:
Invalid object:
Found more than 100 URLMap entries in application configuration
  in "\AppPest\app.yaml", line 269, column 28

我尝试更改文件 appinfo.py 中的设置 MAX_URL_MAPS = 1000,但没有成功。谁能给我一些建议?

编辑:

另一个问题是我的一些 URL 是相似的,比如 a_input.html、b_input.html、c_input.html。有没有办法简化它以减少 URL 的数量?这是我的 yaml 文件的示例

#a
- url: /a_input.html
  script: a/a_input.py
 
#b
- url: /b_input.html
  script: b/b_input.py

#c
- url: /c_input.html
  script: c/c_input.py

【问题讨论】:

    标签: google-app-engine yaml


    【解决方案1】:

    解决方案取决于您使用的语言。如果您使用的是 python 2.7,您可以做的是:

    1) 使用正则表达式来定义网址,详情请参阅this doc

    handlers:
    - url: /(.*?)_input.html
      script: /input/\1.app
    

    2) 将一组 url 指向同一个应用程序,让应用程序处理不同的请求。

    handlers:
    - url: /(.*?)_input.html
      script: /input/input.app
    
    app = webapp2.WSGIApplication([('/a_input.html', AInputPage), ('/b_input.html', BInputPage)])
    

    根据您提供的信息,我无法判断 a_input.html、b_html 是否是静态的。但如果它们是静态的,你也可以这样做:

    3) 使用static file handlers 引用它们,它也接受正则表达式。

    - url: /input
      static_dir: static/input
    

    更多细节请见issue 1444,特别是java相关的。

    【讨论】:

    • 感谢您的帮助。我喜欢对 URL 进行分组的方式,但我的情况是否可行(请参阅我的编辑)?
    • 是的,您需要使用方法1),请参考我指出的文档。这是代码(抱歉,cmets 中没有格式):- url: /(.*?)_input.html 脚本:\1/\1_input.py。下次,请指定您使用的运行时。
    【解决方案2】:

    我在使用 Java SDK 时遇到了同样的问题。 我从欢迎文件列表中删除了 index.html。 现在我的入口点是 index.jsp 并重定向到我的 index.html 页面。

    在 web.xml 中:

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    

    在 appengine-web.xml 中:

    <static-files>
        <include path="/fonts/**" />
        <include path="/app/fonts/**" />
        <include path="/**.html" />
        <include path="/**.js" />
        <include path="/**.css" />
        <include path="/**.ico" />
        <include path="/**.png" />
        <include path="/**.jpg" />
        <include path="/**.jpeg" />
        <include path="/**.gif" />
    </static-files>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-10
      • 2015-03-22
      相关资源
      最近更新 更多