我正在使用 Google App Engine 提供的 urlfetch 来获取 URL 内容。但我收到 500 内部服务器错误。
这是我正在使用的完整应用程序代码:-
比较-hatke.py
import urllib2
from google.appengine.api import urlfetch
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import datetime
class MainPage(webapp.RequestHandler):
def curlTry:
url = "http://www.google.com/"
result = urlfetch.fetch(url)
if result.status_code == 200:
print(result.content)
application = webapp.WSGIApplication([('/', MainPage)],debug=True)
def main():
run_wsgi_app(application)
if __name__ == '__main__':
main()
应用程序.yaml
application: compare-hatke
version: 3
runtime: python27
api_version: 1
threadsafe: false
handlers:
- url: /.*
script: compare-hatke.app
这是错误日志。我无法理解他们提到的语法错误
Traceback (most recent call last):
File "/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 196, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 269, in _LoadHandler
raise ImportError('%s has no attribute %s' % (handler, name))
ImportError: <module 'compare-hatke' from '/base/data/home/apps/s~compare-hatke/3.365290288779373200/compare-hatke.pyc'> has no attribute app
请告诉我我在哪里失踪。谢谢 !