GAE - app.yaml 用于静态页面 AND Python
GAE - app.yaml for static page AND Python
我正在尝试为 Google 应用程序创建静态 html 组件(可离线使用),否则 Python。
我似乎无法为此正确配置 app.yaml
文件。
handlers:
# Serve images and JSON as static resources.
- url: /(.+\.(gif|png|jpg|json|ico))$
static_files:
upload: .+\.(gif|png|jpg|json|ico)$
application_readable: true
- url: \/(static)\/(index)\.html
static_files: static//index.html
upload: static\/index.html
- url: /
script: roomusage.app
login: required
secure: always
- url: /welcome
script: roomusage.app
login: required
secure: always
- url: /record
script: record_usage.app
login: required
secure: always
这是我收到的错误消息:
appcfg.py: error: Error parsing C:\gcloud\dev-myapp\app.yaml: Unable to assign value '\/(static)\/(index)\.html' to attribute 'url':
Value '\/(static)\/(index)\.html' for url does not match expression '^(?:(?!\^)/.*|\..*|(\(.).*(?!$).)$'
in "C:\gcloud\dev-myapp\app.yaml", line 25, column 8.
2017-12-08 09:27:50 (Process exited with code 2)
您的 \/(static)\/(index)\.html
模式是无效的 URL 正则表达式模式。
首先 - 模式不能以 \
开头 - 你不需要转义 /
.
模式中的圆括号用于标识位置分组,然后可以在后续语句中通过 </code>、<code>
等将其称为参数,如 static_files
、例如。来自 Handlers elements table 中的 url
行:
url
Required element under handlers. The URL pattern, as a regular
expression. The expression can contain groupings that can be referred
to in the file path to the script with regular expression
back-references. For example, /profile/(.)/(.) would match the
URL /profile/edit/manager and use edit and manager as the
first and second groupings.
如果您不需要这样 grouping/parameters 那么请不要在您的模式中使用圆括号。所以要匹配 /static/index.html
你可以有:
- url: /static/index\.html
static_files: static/index.html
upload: static/index.html
但是你要注意,如果你还有:
- url: /static
static_dir: static
我正在尝试为 Google 应用程序创建静态 html 组件(可离线使用),否则 Python。
我似乎无法为此正确配置 app.yaml
文件。
handlers:
# Serve images and JSON as static resources.
- url: /(.+\.(gif|png|jpg|json|ico))$
static_files:
upload: .+\.(gif|png|jpg|json|ico)$
application_readable: true
- url: \/(static)\/(index)\.html
static_files: static//index.html
upload: static\/index.html
- url: /
script: roomusage.app
login: required
secure: always
- url: /welcome
script: roomusage.app
login: required
secure: always
- url: /record
script: record_usage.app
login: required
secure: always
这是我收到的错误消息:
appcfg.py: error: Error parsing C:\gcloud\dev-myapp\app.yaml: Unable to assign value '\/(static)\/(index)\.html' to attribute 'url':
Value '\/(static)\/(index)\.html' for url does not match expression '^(?:(?!\^)/.*|\..*|(\(.).*(?!$).)$'
in "C:\gcloud\dev-myapp\app.yaml", line 25, column 8.
2017-12-08 09:27:50 (Process exited with code 2)
您的 \/(static)\/(index)\.html
模式是无效的 URL 正则表达式模式。
首先 - 模式不能以 \
开头 - 你不需要转义 /
.
模式中的圆括号用于标识位置分组,然后可以在后续语句中通过 </code>、<code>
等将其称为参数,如 static_files
、例如。来自 Handlers elements table 中的 url
行:
url
Required element under handlers. The URL pattern, as a regular expression. The expression can contain groupings that can be referred to in the file path to the script with regular expression back-references. For example, /profile/(.)/(.) would match the URL /profile/edit/manager and use edit and manager as the first and second groupings.
如果您不需要这样 grouping/parameters 那么请不要在您的模式中使用圆括号。所以要匹配 /static/index.html
你可以有:
- url: /static/index\.html
static_files: static/index.html
upload: static/index.html
但是你要注意,如果你还有:
- url: /static
static_dir: static