1

良い一日!

https://developers.google.com/appengine/docs/python/gettingstarted/helloworld
これは、実行しようとしている Hello World です。

私は見ることができます

Hello, world!
Status: 500

メッセージ。ただし、更新すると「HTTPエラー500」になります。
そして... app.yamlまたはhelloworld.pyのいずれかを再保存した後、appengineは一度だけ良い結果を表示するようです

これは良い結果のトレースです

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] 

これはエラー 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 -


これが私の helloworld.py です

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

私のmain.py。(アプリの代わりにアプリを使用)

import webapp2

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

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

そして 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"


これを引き起こしている手がかりはありますか?

よろしく、

4

1 に答える 1

3

helloworld.apphelloworld.py モジュールでオブジェクトを作成していません。

ラインを見る

app = webapp2.WSGIApplications([...

あなたのmain.pyファイルに?これにより、app.yaml のハンドラーによって参照される main.app オブジェクトが作成さscript: main.appれます。

helloworld.app数行上のオブジェクトを参照しています。そのオブジェクトは存在しません。App Engine の Python 2.7 は、2.5 の「Hello World」デモで使用されている単純なモジュール モデル (WSGI ハンドラがなく、単純なスクリプトのみ) をサポートしていません。

presveva が言ったように、混乱を避けるために 2.7 Getting Started ガイドを使用してください。

于 2012-06-23T03:12:49.857 に答える