riemaxi
riemaxi

Reputation: 151

mapping values are not allowed here ... in foo.py

I have this GAE python code

In file 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)

in file app.yaml

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

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

I get this error pointing to the third line in file foo.py ( class MainPage(webapp2.RequestHandler): ) Obs. Begin reading from the end of the message

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

I would appreciate a good help

thanks Sam

Upvotes: 9

Views: 3276

Answers (2)

Finn Årup Nielsen
Finn Årup Nielsen

Reputation: 6736

This kind of error occurs if you start the application the wrong way: dev_appserver.py foo.py. You need a directory, e.g., foo with foo/foo.py and foo/app.yaml and then start the program from the parent directory with dev_appserver.py foo/ or in the directory itself with dev_appserver.py .

Upvotes: 16

dansalmo
dansalmo

Reputation: 11704

There is nothing wrong with your code. I copy and pasted both into files and ran them on my Win7 system using App Engine SDK release: "1.7.7" and it served up the page without errors.

You may have issues with the files or your setup.

Have you tried the File->Creating New Application menu option? It will create a new application called engineapp that will display "Hello world!" when browsed on the localhost machine.

Upvotes: 0

Related Questions