本文介绍了谷歌应用引擎:错误:HTTPError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 python 尝试Hello world"

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"

但是在 Google App Launcher 中运行时出现此错误

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)Googlegoogle_app_enginelibcherrypycherrypywsgiserverwsgiserver2.py", line 1302, in communicate
    req.respond()
  File "C:Program Files (x86)Googlegoogle_app_enginelibcherrypycherrypywsgiserverwsgiserver2.py", line 831, in respond
    self.server.gateway(self).respond()
  File "C:Program Files (x86)Googlegoogle_app_enginelibcherrypycherrypywsgiserverwsgiserver2.py", line 2115, in respond
    response = self.req.server.wsgi_app(self.env, self.start_response)
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengine	oolsdevappserver2wsgi_server.py", line 246, in __call__
    return app(environ, start_response)
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengine	oolsdevappserver2
equest_rewriter.py", line 311, in _rewriter_middleware
    response_body = iter(application(environ, wrapped_start_response))
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengine	oolsdevappserver2python
equest_handler.py", line 89, in __call__
    self._flush_logs(response.get('logs', []))
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengine	oolsdevappserver2python
equest_handler.py", line 220, in _flush_logs
    apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengineapiapiproxy_stub_map.py", line 94, in MakeSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengineapiapiproxy_stub_map.py", line 320, in MakeSyncCall
    rpc.CheckSuccess()
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengineapiapiproxy_rpc.py", line 156, in _WaitImpl
    self.request, self.response)
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengineext
emote_api
emote_api_stub.py", line 200, in MakeSyncCall
    self._MakeRealSyncCall(service, call, request, response)
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengineext
emote_api
emote_api_stub.py", line 226, in _MakeRealSyncCall
    encoded_response = self._server.Send(self._path, encoded_request)
  File "C:Program Files (x86)Googlegoogle_app_enginegoogleappengine	oolsappengine_rpc.py", line 393, in Send
    f = self.opener.open(req)
  File "C:Python27liburllib2.py", line 410, in open
    response = meth(req, response)
  File "C:Python27liburllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:Python27liburllib2.py", line 448, in error
    return self._call_chain(*args)
  File "C:Python27liburllib2.py", line 382, in _call_chain
    result = func(*args)
  File "C:Python27liburllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 503: Service Unavailable

我更改了 GAE Launcher(1.7.7) 版本并重新安装了 python 但不起作用

I change GAE Launcher(1.7.7) version and reinstall python but does not work

我使用的是 Windows 7、python 2.7 和 EAG Launcher 1.8.0

I'm using Windows 7, python 2.7 and EAG Launcher 1.8.0

推荐答案

我在 MacOSX 上遇到了同样的问题,在代理服务器后面使用 Google App Engine Launcher 1.8.6 的代理服务器.显然,urllib2.py"上的proxy_bypass"存在问题.

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:

  1. 降级到 1.7.5,但是,谁想降级?
  2. 编辑[GAE 安装路径]/google/appengine/tools/appengine_rpc.py"并查找显示

  1. Downgrade to 1.7.5, but, who wants to downgrade?
  2. Edit "[GAE Instalattion path]/google/appengine/tools/appengine_rpc.py" and look for the line that says

opener.add_handler(fancy_urllib.FancyProxyHandler())

在我的电脑中它是第 578 行,然后在该行的开头放一个哈希 (#),如下所示:

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())`

保存文件,停止然后重新启动您的应用程序.现在 dev_appserver.py 根本不应该尝试使用任何代理服务器.

Save the file, stop and then restart your application. Now dev_appserver.py shouldn't try to use any proxy server at all.

如果您的应用程序使用任何外部资源,例如 SOAP Web 服务或类似的东西,并且您在没有代理服务器的情况下无法访问服务器,那么您将不得不降级.请记住,外部 javascript 文件(如 facebook SDK 或类似文件)是从您的浏览器加载的,而不是从您的应用程序加载.

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.

因为我没有使用任何外部 REST 或 SOAP 服务,所以它对我有用!

Since I'm not using any external REST or SOAP services it worked for me!

希望它也适用于您.

这篇关于谷歌应用引擎:错误:HTTPError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 05:55