Python 此处不允许映射值。。。在foo.py中

Python 此处不允许映射值。。。在foo.py中,python,google-app-engine,Python,Google App Engine,我有这个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.WSGIAppl

我有这个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(类MainPage(webapp2.RequestHandler))中的第三行 Obs。从信息的末尾开始阅读

...
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

如果能帮上忙,我将不胜感激

谢谢
Sam

您的代码没有问题。我复制并粘贴了这两个文件,并使用AppEngineSDK版本“1.7.7”在我的Win7系统上运行了它们,它在页面上没有出现错误

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


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

如果以错误的方式启动应用程序,则会发生此类错误:
dev\u appserver.py foo.py
。您需要一个目录,例如,带有
foo/foo.py
foo/app.yaml
foo
,然后使用
dev_appserver.py foo/
从父目录启动程序,或者在带有
dev_appserver.py的目录本身中启动程序。

我不确定为什么会这样做,但我认为它试图将Python脚本作为YAML文件读取。这也是我的问题所在。非常感谢。