Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine Google应用程序引擎中的默认文档_Google App Engine - Fatal编程技术网

Google app engine Google应用程序引擎中的默认文档

Google app engine Google应用程序引擎中的默认文档,google-app-engine,Google App Engine,是否可以为Google App Engine中的目录指定与默认文档等效的文档,以便导航到该目录时自动重定向到其index.html(例如,如果该目录包含index.html) 如果我的app.yaml中有此项: - url: /demos static_dir: demos 而demos目录包含index.html页面,如何让App Engine自动重定向到该页面?App Engine使用请求路径上的正则表达式匹配来确定要调用的脚本或要提供的文档。如果您只有一个索引文档,您可以这样做: -

是否可以为Google App Engine中的目录指定与默认文档等效的文档,以便导航到该目录时自动重定向到其index.html(例如,如果该目录包含index.html)

如果我的app.yaml中有此项:

- url: /demos
  static_dir: demos

而demos目录包含index.html页面,如何让App Engine自动重定向到该页面?

App Engine使用请求路径上的正则表达式匹配来确定要调用的脚本或要提供的文档。如果您只有一个索引文档,您可以这样做:

- url: /demos/
  static_files: demos/index.html
  upload: demos/index\.html
- url: /(.*)/
  static_files: \1/index.html
  upload: .*/index\.html
一般来说,您可以为以斜杠(“目录”)结尾的路径定义静态文件,如下所示:

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

对于GAE/J,将以下内容添加到web.xml文件中

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

index.html

www.example.com/test/
现在将服务于
www.example.com/test/index.html

我通过在yaml中使用它来实现这一点

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

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

用演示替换静态,您应该被设置。它将空白域重定向到索引X.html和ALL其他文件夹到静态文件夹。

您应该弄清您在GAE上使用的编程语言。我要猜Python?所以答案是“不是真的”,但这很接近。@dez这和你期望的有什么不同?耶!这在许多以前的尝试都没有实现的情况下起作用。谢谢我相信OP是在问如何在python项目中做到这一点。我想
(/。+)
(管道是或)和
(/。+)?
之间没有区别,后者对我来说似乎更清楚。我还使用了
/.*
而不是
/.+
,这样用户就可以输入一些奇怪的东西,比如
/demos/
- url: /demos(/.+|)/
  static_files: demos\1/index.html
  upload: demos/(.+/|)index\.html
- url: /demos/
  static_dir: demos