2010-10-02 71 views
5

在Java中,web.xml可能包含一些<welcome-file>元素。我想在python中做一些相當於沒有運氣的東西。如何聲明app.yaml中的歡迎文件(例如index.html)

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

handlers: 
- url:/
    static_dir: docs 

welcome_files: 
- index.html 

有什麼想法?我收到一個「welcome_files」未被理解的錯誤。

回答

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 
+0

這是正確的。 'welcome_file'只存在於Java中,因爲Java配置不支持這一點。 – 2010-10-02 14:33:32

+0

Robert,請參閱下面的@Karens'答案並修改你的答案。謝謝! – 2015-09-25 20:11:54

1

羅伯特的回答沒有工作了。您必須執行以下操作:

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

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

不能在'upload'中使用regexp'\ 1'。將最後一行更改爲'upload:static /.*' – 2015-09-25 20:14:54

0

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

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

- url:/
    static_dir: static