在使用 YAML 和 Google App Engine 时遇到问题

Having trouble with YAML and the Google App Engine

本文关键字:Engine 遇到 问题 App Google YAML      更新时间:2023-09-26

有人可以帮我解决这个问题吗(我是 YAML 的新手):

application: baking-tutorial
version: secureable
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /robots'.txt
static_files: static/robots.txt
upload: static/robots'.txt
- url: /static
static_dir: static
secure: optional
- url: /main'.html
mime_type: text/html
static_files: static/'1
upload: static/main'.html
- url: /static/.*
 script: mirror.app
 secure: optional
- url: /.*
script: mirror2.app
secure: optional

基本上,我正在尝试托管一个受密码保护的站点,所以我有 mirror2.app 将您定向到它,然后如果您做对了,JavaScript 会将您重定向到主站点.html除非它不存在。

您的文件不是正确的 YAML 文件。您必须注意将所有内容正确缩进到属于一起的同一级别:

application: baking-tutorial
version: secureable
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /robots'.txt
  static_files: static/robots.txt
  upload: static/robots'.txt
- url: /static
  static_dir: static
  secure: optional
- url: /main'.html
  mime_type: text/html
  static_files: static/'1
  upload: static/main'.html
- url: /static/.*
  script: mirror.app
  secure: optional
- url: /.*
  script: mirror2.app
  secure: optional
映射

键"处理程序"的值是映射列表。后一种映射中的每一个都至少有一个"url"键,然后是其他一些键。

在 YAML 中,如果缩进到上一个级别,则基本上结束了上一个构造(序列、映射)。另请注意,映射值中列表项的-可以与键对齐(不必如此,只要它们都缩进同一级别即可,它们可以更缩进)。