python - Google应用程序引擎本地主机服务器错误python

标签 python google-app-engine python-2.7 internal-server-error

我只是想在谷歌应用程序引擎中运行 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/

相关文章:

python - 运行使用 Python 创建的命令行工具

mongodb - 如何在 MongoDB 中关闭游标

python - 存储永久数据的最佳实践?

python - 在 GAE 中组合文本搜索和查询过滤器

python - 将 Blob 从一个 AppEngine 应用程序复制到另一个

python - python - 如何按两列或多列对python pandas中的dataFrame进行排序?

python - 在 tensorflow docker 图像上启动 convolutional.py 脚本时为 "No such file or directory"

python - 如何查看 Python 对象内部?

python - 如何使用 NiBabel (Python) 预处理 NIfTI 数据格式

python - Google Appengine 上的登录 Hook