app.yaml遇到问题

时间:2017-07-31 20:30:08

标签: google-app-engine google-app-engine-python app.yaml

基本上我的目录布局如下所示:

- demo
|
+ + exmaple1
| |
| + index.html
| + some-script.js
|
+ + example2
...

我想要实现的目标是

my.url/demo/example1                 shows  /demo/example1/index.html
my.url/demo/example1/some-script.js  shows  /demo/example1/some-script.js
my.url/demo/example1/index.html      redirects to  my.url/demo/example1

这是我的app.yaml:

handlers:
# some stuff here
- url: /demo/([^/]+)$
  static_files: demo/\1/index.html
  upload: demo/(.+)/index\.html$

- url: /demo
  static_dir: demo

确实会返回my.url/demo/example1的正确页面,但是当我尝试请求my.url/demo/example1/some-script.js时,它会返回404.为什么会这样,我该如何解决?

1 个答案:

答案 0 :(得分:0)

您没有.js文件的处理程序。通过"重定向",你的意思是完整的301重定向,还是只显示index.html静态文件?   这样做你需要的吗?

- url: /demo/(.*)/(.*)
  static_files: demo/\1/\2
  upload: demo/(.*)/(.*)

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