2012-06-23 37 views
1

美好的一天跑了!

https://developers.google.com/appengine/docs/python/gettingstarted/helloworld
這是我試圖運行Hello World。

我可以看到
GAE簡單的請求處理程序只有一次

Hello, world! 
Status: 500 

消息。但是在刷新後它會變成「HTTP Error 500」。
和......似乎AppEngine上只顯示我的好成績,一旦我以後再救不app.yaml中或helloworld.py

這是很好的結果

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" 


任何線索是什麼造成的?

問候,

+0

您正在使用python27:請參閱相關[入門](https://developers.google.com/appengine/docs/python/gettingstartedpython27/helloworld) –

回答

3

您還沒有創建helloworld.py模塊中的helloworld.app對象。

查看您main.py文件中的行

app = webapp2.WSGIApplications([... 

?這將創建的方法是,你的app.yaml的script: main.app處理程序中引用的main.app對象。

你引用helloworld.app對象兩行以上的;該對象不存在。 App Engine中的Python 2.7不支持簡單模塊模型 - 沒有WSGI處理程序,只是一個簡單的腳本 - 用於2.5「Hello World」演示。

正如presveva說,使用2.7入門指南減少混亂。

+1

謝謝!!!!!終於解開了謎團! 在一起時,googleAPI +的oauth2問題解決得! 以前我以爲* .app爲2.7 == * .py爲2.5 XD哈哈 – Hiro