[英]Google App Engine | Python | APP.YAML
I am a beginner to Google App Engine, as well as web-development in Python. 我是Google App Engine的初学者,也是Python的Web开发人员。 After making a small Python based app, I have been trying for the past 6 days to get it uploaded on GAE. 在制作了一个基于Python的小应用程序后,我一直在尝试过去6天将其上传到GAE上。 The "app.yaml" file below gives the error given after that. 下面的“app.yaml”文件给出了之后给出的错误。
application: web2py
version: 1
runtime: python27
api_version: 1
threadsafe: false
default_expiration: "24h"
handlers:
- url: /(?P<a>.+?)/static/(?P<b>.+)
static_files: applications/\1/static/\2
upload: applications/(.+?)/static/(.+)
secure: optional
- url: /favicon.ico
static_files: applications/welcome/static/favicon.ico
upload: applications/welcome/static/favicon.ico
- url: /robots.txt
static_files: applications/welcome/static/robots.txt
upload: applications/welcome/static/robots.txt
- url: .*
# script: gaehandler.py # CGI
# script: web2py.app # ?
script: gaehandler.wsgiapp # WSGI (Python 2.7 only)
secure: optional
admin_console:
pages:
- name: Appstats
url: /_ah/stats
skip_files: |
^(.*/)?(
(app\.yaml)|
(app\.yml)|
(index\.yaml)|
(index\.yml)|
(#.*#)|
(.*~)|
(.*\.py[co])|
(.*/RCS/.*)|
(\..*)|
(applications/(admin|examples)/.*)|
((admin|examples)\.(w2p|tar))|
(applications/.*?/(cron|databases|errors|cache|sessions)/.*)|
((logs|scripts)/.*)|
(anyserver\.py)|
(web2py\.py)|
((cgi|fcgi|modpython|wsgi)handler\.py)|
(epydoc\.(conf|css))|
(httpserver\.log)|
(logging\.example\.conf)|
(route[rs]\.example\.py)|
(setup_(app|exe)\.py)|
(splashlogo\.gif)|
(parameters_\d+\.py)|
(options_std.py)|
(gluon/tests/.*)|
(gluon/(rocket|winservice)\.py)|
(contrib/(gateways|markdown|memcache|pymysql)/.*)|
(contrib/(populate|taskbar_widget)\.py)|
(google_appengine/.*)|
(.*\.(bak|orig))|
)$
builtins:
- remote_api: on
- appstats: on
- admin_redirect: on
- deferred: on
Google App Engine while using Python 2.7.3 gives the following Error 使用Python 2.7.3时,Google App Engine会出现以下错误
*** Running dev_appserver with the following flags:
--admin_console_server= --port=8080 --use_sqlite
Python command: /usr/local/bin/python2.7
ERROR 2012-11-22 05:24:13,142 dev_appserver_main.py:626] Fatal error when loading application configuration:
mapping values are not allowed here
in "/Applications/+++WWW+++/GAE/gae3web2py/app.yaml", line 9, column 9
If anyone can kindly help me, I shall be very thankful, especially on this day of American "Thanksgiving" ! 如果有人能帮助我,我会非常感激,尤其是在美国“感恩节”的这一天! ;-) ;-)
The "app.yaml" file was updated with the spacing as suggested. 使用建议的间距更新“app.yaml”文件。 But it still gives that same error. 但它仍然会给出同样的错误。
I even tried it here, where it gives the same errors: Link > http://yaml-online-parser.appspot.com/ 我甚至在这里尝试了它,它给出了同样的错误: 链接 > http://yaml-online-parser.appspot.com/
When configuring your app.yaml
, you need to separate all parameters from their values with spaces (so application:web2py
should be application: web2py
, etc.). 配置app.yaml
,需要使用空格将所有参数与其值分开(因此application:web2py
应该是application: web2py
等)。 Try dropping a space in after the colons (specifically after this one: url:/(?P<a>.+?)/static/(?P<b>.+)
) and see if that fixes the error. 尝试在冒号后面放一个空格(特别是在这一个之后: url:/(?P<a>.+?)/static/(?P<b>.+)
)并查看是否修复了错误。
It's an issue with your YAML
syntax. 这是您的YAML
语法的问题。 If you're ever confused about the syntax, you can find the spec here. 如果您对语法感到困惑, 可以在此处找到规范。 . 。
From section 2.1 - Collections: 从第2.1节 - 集合:
YAML's block collections use indentation for scope and begin each entry on its own line. YAML的块集合使用缩进作为范围并在其自己的行上开始每个条目。 Block sequences indicate each entry with a dash and space ( “- ”). 块序列用短划线和空格(“ - ”)表示每个条目。 Mappings use a colon and space (“: ”) to mark each key: value pair. 映射使用冒号和空格(“:”)来标记每个键:值对。 Comments begin with an octothorpe (also called a “hash”, “sharp”, “pound”, or “number sign” - “#”). 注释以octothorpe开头(也称为“hash”,“sharp”,“pound”或“number sign” - “#”)。
Try removing all the succeeding space after :
尝试删除以下所有后续空格:
This worked for me, although there were some other bugs in my app.yaml
that I have not yet corrected. 这对我app.yaml
,虽然我的app.yaml
还有一些其他错误,我还没有纠正。
I'm not sure what Google GAE uses to interpret the YAML file, but to PyYAML that file is not acceptable because of the \\
in the value for static_files
. 我不知道谷歌GAE用来解释YAML文件,但PyYAML该文件是不是因为接受\\
中的价值static_files
。
This also happens to be the 9th line of the file (leaving out empty lines). 这也恰好是文件的第9行(省略空行)。 So I would start by escape those values. 所以我会先逃避这些价值观。
Please note that http://yaml-online-parser.appspot.com/ now just parses your exmaple, but it silently seems to convert the \\1
to '\\2' before passing the data from the textarea to PyYAML. 请注意, http : //yaml-online-parser.appspot.com/现在只是解析你的exmaple,但在将数据从textarea传递给PyYAML之前,它似乎默默地将\\1
转换为'\\ 2'。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.