【问题标题】:How to declare the welcome file (e.g. index.html) in app.yaml如何在 app.yaml 中声明欢迎文件(例如 index.html)
【发布时间】:2011-04-20 03:23:43
【问题描述】:

在 Java 中,web.xml 可能包含一些 <welcome-file> 元素。我正在尝试在 python 中做一些等效的事情,但没有运气。

application: wk
version: 1
runtime: python
api_version: 1

handlers:
- url: /
  static_dir: docs

welcome_files:
- index.html

有什么想法吗?我收到“welcome_files”不被理解的错误。

【问题讨论】:

    标签: python google-app-engine configuration yaml


    【解决方案1】:

    一种可能性:

    application: wk
    version: 1
    runtime: python
    api_version: 1
    
    handlers:
    - url: /
      static_files: static/index.html
      upload: static/index.html
    
    - url: /.*
      static_files: static
      upload: static
    

    【讨论】:

    • 这是正确的。 'welcome_file' 仅存在于 Java 中,因为 Java 配置不支持此功能。
    • 罗伯特,请参阅下面@Karens 的答案并修改您的答案。谢谢!
    【解决方案2】:

    罗伯特的回答不再有效。您必须执行以下操作:

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

    【讨论】:

    • 不能在upload 中使用正则表达式\1。将最后一行更改为upload: static/.*
    【解决方案3】:

    将空字符串路由到 index.html。

    - url: /$
      static_files: static/index.html
      upload: static/index.html
    
    - url: /
      static_dir: static
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-16
      • 1970-01-01
      • 1970-01-01
      • 2011-12-05
      • 2013-10-17
      • 1970-01-01
      • 2023-03-08
      相关资源
      最近更新 更多