谷歌应用程序引擎:错误:HTTPError [英] google app engine: Error: HTTPError
问题描述
import webapp2
class MainHandler(webapp2 .RequestHandler):
def get(self):
self.response.write('Hello world!')
app = webapp2.WSGIApplication([
( '/',MainHandler)
],debug = True)
app.yaml
应用程序:engineapp
版本:1
运行时:python27
api_version:1
threadsafe:是
处理程序:
- url:/favicon\.ico
static_files:favicon.ico
上传:favicon\.ico
- url:。*
script:main.app
库:
- 名称:webapp2
版本:2.5.2
但在Google App Launcher中运行时出现此错误
INFO 2013-05-22 12:22:40,302 admin_server.py:117]从以下位置启动管理服务器:xxxxx:8000
HTTPError()
HTTPError()
追踪(最近最后一次呼叫):
F ileC:\ Program Files(x86)\Google\google_app_engine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py,第1302行,沟通
req.respond()
文件C:\ Program Files(x86)\Google\google_app_engine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py,第831行,回应
self .server.gateway(self).respond()
文件C:\程序文件(x86)\Google\google_app_engine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py ,第2115行,响应
response = self.req.server.wsgi_app(self.env,self.start_response)
文件C:\程序文件(x86)\Google\google_app_engine\\ \\ google \appengine\tools\devappserver2\wsgi_server.py,第246行,在__call__
返回应用程序(environ,start_response)
文件C:\程序文件(x86) \\Google\google_app_engine\google\appengine\tools\d evappserver2\request_rewriter.py,第311行,位于_rewriter_middleware
response_body = iter(application(environ,wrapped_start_response))
文件C:\程序文件(x86)\Google\google_app_engine\\ \\google \appengine\tools\devappserver2\python\request_handler.py,第89行,在__call__
self._flush_logs(response.get('logs',[]))
文件C:\程序文件(x86)\Google\google_app_engine\google\appengine\tools\devappserver2\python\request_handler.py,第220行,位于_flush_logs
apiproxy_stub_map中。 MakeSyncCall('logservice','Flush',request,response)
文件C:\程序文件(x86)\Google\google_app_engine\google\appengine\api\apiproxy_stub_map.py ,第94行,在MakeSyncCall
返回stubmap.MakeSyncCall(服务,调用,请求,响应)
文件C:\程序文件(x86)\Google\google_app_engine\\ google \appengine\api\apiproxy_stub_map.py,行320,在MakeSyncCall
rpc.CheckSuccess()
文件C:\程序文件(x86)\Google\google_app_engine\\ \google\appengine\api\apiproxy_rpc.py,第156行,位于_WaitImpl
self.request,self.response)
文件C:\程序文件(x86)\Google \google_app_engine\google\appengine\ext\remote_api\remote_api_stub.py,第200行,在MakeSyncCall
self._MakeRealSyncCall(服务,呼叫,请求,响应)
文件C :\程序文件(x86)\Google\google_app_engine\google\appengine\ext\remote_api\remote_api_stub.py,行226,在_MakeRealSyncCall
encoded_response = self._server.Send( self._path,encoded_request)
在Send $ b中的文件C:\程序文件(x86)\Google\google_app_engine\google\appengine\tools\appengine_rpc.py,第393行$ bf = self.opener.ope n(req)
文件C:\Python27\lib\urllib2.py,第410行,打开
response = meth(req,response)
文件C: \Python27\lib\urllib2.py,第523行,在http_response
'http',request,response,code,msg,hdrs)
文件C:\Python27\lib \urllib2.py,第448行,错误
返回self._call_chain(* args)
在_call_chain中的文件C:\Python27\lib\urllib2.py,第382行
result = func(* args)
文件C:\Python27\lib\urllib2.py,第531行,在http_error_default
中引发HTTPError(req.get_full_url(),代码,msg,hdrs,fp)
HTTPError:HTTP错误503:服务不可用
I更改GAE Launcher(1.7.7)版本并重新安装python,但无法正常工作
我使用Windows 7,Python 2.7和EAG Launcher 1.8.0
使用代理服务器时,我的MacOSX存在同样的问题呃在代理服务器后面使用Google App Engine Launcher 1.8.6。显然,在urllib2.py上有一个proxy_bypass的问题。
有两种可能的解决方案:
- 降级到1.7.5,但是谁愿意降级?
-
编辑[GAE Instalattion路径] / google / appengine / tools / appengine_rpc .py,然后查找一行说:
opener.add_handler(fancy_urllib.FancyProxyHandler())
$在我的计算机中,它是第578行,然后在行的开头放置一个散列(#),就像这样:
`#opener.add_handler(fancy_urllib.FancyProxyHandler())`
保存文件,停止并重新启动应用程序。现在,dev_appserver.py不应该尝试使用任何代理服务器。
如果您的应用程序使用任何外部资源,如SOAP Webservice或类似的东西,无法使用代理服务器到达服务器,那么您必须降级。请记住,外部JavaScript文件(如Facebook SDK或类似的)从您的浏览器加载,而不是从您的应用程序。
因为我没有使用任何外部REST或SOAP服务,所以对我很有用!
希望它会为你工作。
I am trying "Hello world" with python
import webapp2 class MainHandler(webapp2.RequestHandler): def get(self): self.response.write('Hello world!') app = webapp2.WSGIApplication([ ('/', MainHandler) ], debug=True)
app.yaml
application: engineapp version: 1 runtime: python27 api_version: 1 threadsafe: yes handlers: - url: /favicon\.ico static_files: favicon.ico upload: favicon\.ico - url: .* script: main.app libraries: - name: webapp2 version: "2.5.2"
But when run in Google App Launcher get this error
INFO 2013-05-22 12:22:40,302 admin_server.py:117] Starting admin server at: xxxxx:8000 HTTPError() HTTPError() Traceback (most recent call last): File "C:\Program Files (x86)\Google\google_app_engine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py", line 1302, in communicate req.respond() File "C:\Program Files (x86)\Google\google_app_engine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py", line 831, in respond self.server.gateway(self).respond() File "C:\Program Files (x86)\Google\google_app_engine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py", line 2115, in respond response = self.req.server.wsgi_app(self.env, self.start_response) File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\tools\devappserver2\wsgi_server.py", line 246, in __call__ return app(environ, start_response) File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\tools\devappserver2\request_rewriter.py", line 311, in _rewriter_middleware response_body = iter(application(environ, wrapped_start_response)) File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\tools\devappserver2\python\request_handler.py", line 89, in __call__ self._flush_logs(response.get('logs', [])) File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\tools\devappserver2\python\request_handler.py", line 220, in _flush_logs apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response) File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\api\apiproxy_stub_map.py", line 94, in MakeSyncCall return stubmap.MakeSyncCall(service, call, request, response) File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\api\apiproxy_stub_map.py", line 320, in MakeSyncCall rpc.CheckSuccess() File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\api\apiproxy_rpc.py", line 156, in _WaitImpl self.request, self.response) File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\ext\remote_api\remote_api_stub.py", line 200, in MakeSyncCall self._MakeRealSyncCall(service, call, request, response) File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\ext\remote_api\remote_api_stub.py", line 226, in _MakeRealSyncCall encoded_response = self._server.Send(self._path, encoded_request) File "C:\Program Files (x86)\Google\google_app_engine\google\appengine\tools\appengine_rpc.py", line 393, in Send f = self.opener.open(req) File "C:\Python27\lib\urllib2.py", line 410, in open response = meth(req, response) File "C:\Python27\lib\urllib2.py", line 523, in http_response 'http', request, response, code, msg, hdrs) File "C:\Python27\lib\urllib2.py", line 448, in error return self._call_chain(*args) File "C:\Python27\lib\urllib2.py", line 382, in _call_chain result = func(*args) File "C:\Python27\lib\urllib2.py", line 531, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) HTTPError: HTTP Error 503: Service Unavailable
I change GAE Launcher(1.7.7) version and reinstall python but does not work
I'm using Windows 7, python 2.7 and EAG Launcher 1.8.0
解决方案I had this very same issue with my MacOSX when using a proxy server using Google App Engine Launcher 1.8.6 behind a proxy server. Apparently there's an issue with "proxy_bypass" on "urllib2.py".
There are two possible solutions:
- Downgrade to 1.7.5, but, who wants to downgrade?
Edit "[GAE Instalattion path]/google/appengine/tools/appengine_rpc.py" and look for the line that says
opener.add_handler(fancy_urllib.FancyProxyHandler())
In my computer it was line 578, and then put a hash (#) at the beginning of the line, like this:
`#opener.add_handler(fancy_urllib.FancyProxyHandler())`
Save the file, stop and then restart your application. Now dev_appserver.py shouldn't try to use any proxy server at all.
If your application uses any external resources like a SOAP Webservice or something like that and you can't reach the server without the proxy server, then you'll have to downgrade. Please keep in mind that external javascript files (like facebook SDK or similar) are loaded from your browser, not from your application.
Since I'm not using any external REST or SOAP services it worked for me!
Hopefully it will work for you as well.
这篇关于谷歌应用程序引擎:错误:HTTPError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!