GAE-app.yaml用于静态页面和Python
我正在尝试为一个Google应用程序创建一个静态html组件(该组件可以脱机使用),否则它就是Python 我似乎无法为此正确配置GAE-app.yaml用于静态页面和Python,python,google-app-engine,static,app.yaml,Python,Google App Engine,Static,App.yaml,我正在尝试为一个Google应用程序创建一个静态html组件(该组件可以脱机使用),否则它就是Python 我似乎无法为此正确配置app.yaml文件 handlers: # Serve images and JSON as static resources. - url: /(.+\.(gif|png|jpg|json|ico))$ static_files: \1 upload: .+\.(gif|png|jpg|json|ico)$ application_readabl
app.yaml
文件
handlers:
# Serve images and JSON as static resources.
- url: /(.+\.(gif|png|jpg|json|ico))$
static_files: \1
upload: .+\.(gif|png|jpg|json|ico)$
application_readable: true
- url: \/(static)\/(index)\.html
static_files: static/\1/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)
您的\/(静态)\/(索引)\.html
模式是无效的URL正则表达式模式
首先-模式不能以\
开头-您不需要转义/
模式中的圆形参数用于识别位置分组,这些位置分组可以在后续语句中被\1
、\2
等称为参数,例如静态文件
。从表中的url
行:
url
处理程序下的必需元素。URL模式,作为常规
表示表达式可以包含可引用的分组
使用正则表达式在脚本的文件路径中
反向引用。例如,/profile/(.)/(.)将匹配
URL/profile/edit/manager并使用编辑和管理器作为
第一组和第二组
如果您不需要这样的分组/参数,那么就不要在模式中使用圆形参数。因此,为了只匹配/static/index.html
,您可以:
- url: /static/index\.html
static_files: static/index.html
upload: static/index.html
但是,您应该注意,如果您还拥有:
- url: /static
static_dir: static
\/(静态)\/(索引)\.html
模式可能是可疑的。您试图与之匹配的URL以及要在其中标识的参数是什么?我试图与之匹配的URL:/static/index.html
(不理解问题的第二部分)