google应用程序引擎python hello world应用程序在本地主机上不显示任何内容:8080

google应用程序引擎python hello world应用程序在本地主机上不显示任何内容:8080,python,google-app-engine,Python,Google App Engine,我用python运行了以下hello world代码,但localhost:8080不打印任何内容 我正在使用ubuntu 12.04 localhost:8080显示一个空白页 helloworld.py import webapp2 class MainPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.respons

我用python运行了以下hello world代码,但localhost:8080不打印任何内容

我正在使用ubuntu 12.04

localhost:8080显示一个空白页

helloworld.py

import webapp2


class MainPage(webapp2.RequestHandler):

def get(self):
    self.response.headers['Content-Type'] = 'text/plain'
    self.response.write('Hello, World!')


application = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
app.yaml

application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: helloworld.application
结果如下

kiran@kiru-Lenovo-G480:~/google$ dev_appserver.py helloworld/
INFO     2013-10-09 12:22:03,559 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-10-09 12:22:03,565 __init__.py:94] Connecting through tunnel to: appengine.google.com:443
INFO     2013-10-09 12:22:03,571 sdk_update_checker.py:261] Update check failed: <urlopen error Tunnel connection failed: 407 Proxy Authentication Required>
INFO     2013-10-09 12:22:03,595 api_server.py:138] Starting API server at: http://localhost:44748
INFO     2013-10-09 12:22:03,610 dispatcher.py:168] Starting module "default" running at: http://localhost:8080
INFO     2013-10-09 12:22:03,614 admin_server.py:117] Starting admin server at: http://localhost:8000
kiran@kiru-Lenovo-G480:~/google$dev\u appserver.py helloworld/
信息2013-10-09 12:22:03559 sdk_update_checker.py:245]检查sdk的更新。
信息2013-10-09 12:22:03565通过隧道连接到:appengine.google.com:443
信息2013-10-09 12:22:03571 sdk更新检查程序。py:261]更新检查失败:
信息2013-10-09 12:22:03595 api_server.py:138]正在以下位置启动api服务器:http://localhost:44748
INFO 2013-10-09 12:22:03610调度程序.py:168]启动模块“默认值”,运行时间:http://localhost:8080
信息2013-10-09 12:22:03614管理服务器。py:117]正在以下位置启动管理服务器:http://localhost:8000

您直接在
响应
对象上调用
write
。您将希望执行以下操作:

self.response.out.write('Hello, World!')

您的代码似乎没有任何问题。GAE运行时没有错误,并且在浏览器中也没有显示任何错误,这一事实让我认为这可能是一个浏览器/显示问题。尝试以下两种方法:

  • 删除设置“内容类型”的链接,然后
  • 尝试使用正确的html文件而不是文本响应:

    self.response.write(template.render(tvalue))


您不需要看到错误,因为执行情况良好。 问题是代码的缩进。 即 导入webapp2: 类MainHandler(webapp2.RequestHandler): def get(自我): self.response.write('Hello World') app=webapp2.WSGIApplication([('/',MainHandler)],debug=True)


应该与类具有相同的缩进,而不是def

def get的缩进似乎是错误的-应该在类内部缩进。但这可能是复制代码的结果。