更新GAE Python应用的问题

2 投票
1 回答
838 浏览
提问于 2025-04-16 18:00

我在用以下命令把我的应用更新到GAE时遇到了问题:

python appcfg.py update /home/tom/workspace/DjangoProject

出现了一个错误信息:

mapping values are not allowed here
  in "/home/tom/workspace/DjangoProject/app.yaml", line 6, column 9

这是我的yaml文件:

application:myapp
version:1
runtime:python
api_version:1

handlers:
- url:/
  script:home.py

- url:/index\.html
  script: home.py

- url: /stylesheets
  static_dir: stylesheets

- url: /(.*\.(gif|png|jpg))
  static_files: static/\1
  upload: static/(.*\.(gif|png|jpg))

- url: /admin/.*
  script: admin.py
  login: admin

- url: /.*
  script: not_found.py

有人能帮我吗?

我修改了我的yaml文件:

application:myapp
version:1
runtime:python
api_version:1
handlers
- url:/
  script:home.py
- url:/index\.html
  script:home.py
- url:/stylesheets
  static_dir:stylesheets
- url:/(.*\.(gif|png|jpg))
  static_files:static/\1
  upload:static/(.*\.(gif|png|jpg))
- url:/admin/.*
  script:admin.py
  login:admin
- url:/.*
  script:not_found.py

现在错误信息变成了:

google.appengine.api.appinfo_errors.MissingURLMapping: 在应用配置中找不到URL映射条目

1 个回答

1

在冒号后面必须要有空格。这就是为什么你的 app.yaml 文件无法被解析的原因。试试这个

application: myapp
version: 1
runtime: python
api_version: 1

handlers:
- url: /
  script: home.py

- url: /index\.html
  script: home.py

- url: /stylesheets
  static_dir: stylesheets

- url: /(.*\.(gif|png|jpg))
  static_files: static/\1
  upload: static/(.*\.(gif|png|jpg))

- url: /admin/.*
  script: admin.py
  login: admin

- url: /.*
  script: not_found.py

撰写回答