我只是想在谷歌应用程序引擎中运行 hello world 程序。但是当我尝试在浏览器上运行该应用程序时,出现 500 服务器错误。我尝试重新安装 GAE 应用程序引擎启动器和 python 2.7.5。但运气不佳!
这是我的hello.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
app.yaml
application: silent-blend-359
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: hello.application
日志太大所以我把它粘贴到这里http://paste.ubuntu.com/6195427/
已解决
我使用代理连接到互联网。只需禁用代理即可瞧!问题解决了!
最佳答案
缩进是 Python 语法的一部分。正确缩进:
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
并且,替换 app.yaml
中的以下行(hello.py
中没有 application
,但是 app
>):
hello.application
与:
hello.app
hello.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
app.yaml
application: silent-blend-359
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: hello.app
关于python - Google应用程序引擎本地主机服务器错误python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19195142/