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

5 投票
3 回答
2649 浏览
提问于 2025-04-16 04:52

在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”不被理解。

3 个回答

0

把空字符串的请求导向 index.html 文件。

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

- url: /
  static_dir: static
1

罗伯特的回答现在已经不管用了。你需要做以下这些:

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

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

一种可能性是:

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

撰写回答