【问题标题】:mapping values are not allowed here ... in foo.py此处不允许映射值...在 foo.py
【发布时间】:2013-04-19 11:22:09
【问题描述】:

我有这个 GAE python 代码

在文件 foo.py 中

import webapp2

class MainPage(webapp2.RequestHandler):

         def get(self):
                self.response.headers['Content-Type'] = 'text/plain'
                self.response.write('Hello Foo')

app = webapp2.WSGIApplication([('/', MainPage)], debug = True)

在 app.yaml 文件中

application: foo
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: foo.app

我得到这个错误指向文件 foo.py ( class MainPage(webapp2.RequestHandler): ) 中的第三行 观察。从邮件末尾开始阅读

...
line 172, in _HandleEvents
    for event in events:
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/yaml_listener.py", line 212, in _GenerateEventParameters
    raise yaml_errors.EventListenerYAMLError(e)
google.appengine.api.yaml_errors.EventListenerYAMLError: mapping values are not allowed here
  in "foo.py", line 3, column 39

非常感谢您的帮助

谢谢 山姆

【问题讨论】:

  • 我不确定它为什么会这样做,但我认为它正在尝试将您的 Python 脚本读取为 YAML 文件。

标签: python google-app-engine


【解决方案1】:

如果您以错误的方式启动应用程序,则会出现这种错误:dev_appserver.py foo.py。您需要一个目录,例如foofoo/foo.pyfoo/app.yaml,然后使用dev_appserver.py foo/ 从父目录启动程序或使用dev_appserver.py . 在目录本身中启动程序

【讨论】:

  • 这也是我的确切问题。谢谢。
【解决方案2】:

您的代码没有任何问题。我将这两个文件复制并粘贴到文件中,并使用 App Engine SDK 版本在我的 Win7 系统上运行它们:“1.7.7”,它提供的页面没有错误。

您的文件或设置可能有问题。

您是否尝试过“文件”->“创建新应用程序”菜单选项?它将创建一个名为 engineapp 的新应用程序,该应用程序将显示“Hello world!”。在 localhost 机器上浏览时。

【讨论】:

    猜你喜欢
    • 2014-12-13
    • 2019-10-27
    • 2019-08-16
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    • 2019-12-09
    • 2012-02-21
    • 2015-12-14
    相关资源
    最近更新 更多