代码之家  ›  专栏  ›  技术社区  ›  Hamy

如何在app.yaml中声明欢迎文件(如index.html)

  •  5
  • Hamy  · 技术社区  · 15 年前

    在Java中,Web.xml可能包含一些 <welcome-file> 元素。我在尝试用Python做一些类似的事情,但没有运气。

    application: wk
    version: 1
    runtime: python
    api_version: 1
    
    handlers:
    - url: /
      static_dir: docs
    
    welcome_files:
    - index.html
    

    有什么想法吗?我得到一个错误,“欢迎使用文件”是不理解的。

    3 回复  |  直到 15 年前
        1
  •  7
  •   Robert Kluin    15 年前

    一种可能性:

    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
    
        2
  •  1
  •   Karens    11 年前

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

    - url: /
      static_files: static/index.html
      upload: static/index.html
    
    - url: /(.*)
      static_files: static/\1
      upload: static/\1
    
        3
  •  0
  •   Steven VanHorn    10 年前

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

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