簡體   English   中英

GAE-適用於靜態頁面和Python的app.yaml

[英]GAE - app.yaml for static page AND Python

我正在嘗試為否則為Python的Google App創建一個靜態html組件(可離線使用)。

我似乎無法為此正確配置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)

您的\\/(static)\\/(index)\\.html模式是無效的URL正則表達式模式。

首先-模式不能以\\開頭-您不需要轉義/

模式中的圓括號用於識別位置分組,然后在后續語句(例如static_files其稱為\\1\\2等參數。 處理程序元素表中的url行:

網址

處理程序下的必需元素。 URL模式,作為正則表達式。 表達式可以包含可在腳本的文件路徑中使用正則表達式反向引用引用的分組。 例如, / profile /(。 )/(。將匹配URL / profile / edit / manager,並使用editmanager作為第一和第二分組。

如果不需要這樣的分組/參數,則不要在模式中使用圓括號。 因此,僅匹配/static/index.html您可以:

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

但是您應該注意,如果您還具有以下內容,則以上內容是多余的:

- url: /static
  static_dir: static

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM