GAE Simple Request Handler only run once

Posted by Hiro on Stack Overflow See other posts from Stack Overflow or by Hiro
Published on 2012-06-23T02:04:38Z Indexed on 2012/06/23 3:16 UTC
Read the original article Hit count: 276

Good day!

https://developers.google.com/appengine/docs/python/gettingstarted/helloworld
this is the hello world that I'm trying to run.

I can seeing the

Hello, world!
Status: 500

message. however it will be turned to a "HTTP Error 500" after I hit the refresh.
and... it seems that the appengine only shows me the good result once after I re-save either app.yaml or helloworld.py

This is the trace for the good result

Traceback (most recent call last):
  File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 187, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 239, in _LoadHandler
    raise ImportError('%s has no attribute %s' % (handler, name))
ImportError: <module 'helloworld' from 'D:\work\[GAE] tests\helloworld\helloworld.pyc'> has no attribute app
INFO     2012-06-23 01:47:28,522 dev_appserver.py:2891] "GET /hello HTTP/1.1" 200 -
ERROR    2012-06-23 01:47:30,040 wsgi.py:189] 

and this is the trace for the Error 500

Traceback (most recent call last):
  File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 187, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 239, in _LoadHandler
    raise ImportError('%s has no attribute %s' % (handler, name))
ImportError: <module 'helloworld' from 'D:\work\[GAE] tests\helloworld\helloworld.pyc'> has no attribute app
INFO     2012-06-23 01:47:30,127 dev_appserver.py:2891] "GET /hello HTTP/1.1" 500 -


here's my helloworld.py

print 'Content-Type: text/plain'
print ''
print 'Hello, world!'

my main.py. (app is used instead of application)

import webapp2

class hello(webapp2.RequestHandler):
    def get(self):
        self.response.out.write('normal hello')

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

and the app.yaml

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

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /hello
  script: helloworld.app

- url: /.*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.1"


any clue what's causing this?

Regards,

© Stack Overflow or respective owner

Related posts about python

Related posts about google-app-engine