简体   繁体   English

使用python编写的response.out.write,Google App引擎未显示在本地主机上

[英]response.out.write in python, google app engine not displaying on local host

my yaml file: 我的Yaml文件:

application: testprogram
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: main.py

my python file: 我的python文件:

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.reponse.headers['Content-Type'] = 'text/plain'
        self.response.out.write("Hurray for cake!")

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

from the sever: 从服务器:

$ dev_appserver.py testprogram
WARNING  2016-09-01 05:42:36,253 application_configuration.py:165] The "python" runtime specified in "testprogram/app.yaml" is not supported - the "python27" runtime will be used instead. A description of the differences between the two can be found here:
https://developers.google.com/appengine/docs/python/python25/diff27
INFO     2016-09-01 05:42:36,265 sdk_update_checker.py:229] Checking for updates to the SDK.
INFO     2016-09-01 05:42:36,400 sdk_update_checker.py:257] The SDK is up to date.
WARNING  2016-09-01 05:42:36,635 simple_search_stub.py:1146] Could not read search indexes from /tmp/appengine.testprogram.rickus/search_indexes
INFO     2016-09-01 05:42:36,639 api_server.py:205] Starting API server at: http://localhost:40100
INFO     2016-09-01 05:42:36,642 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO     2016-09-01 05:42:36,643 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO     2016-09-01 05:42:51,325 module.py:788] default: "GET / HTTP/1.1" 200 -

sever is up. 服务器断了。 Local host is up. 本地主机已启动。 But nothing is being written out. 但是什么都没有写出来。 I am doing udacitys course so I have just began. 我正在上大学课程,所以我才刚刚开始。 What could the hang up be. 挂断电话可能是什么。 Been checking the docs and still lost. 正在检查文档,但仍然丢失。

In the .yaml file, point the routing handler to main.app (not main.py). .yaml文件中,将路由处理程序指向main.app(而不是main.py)。

You also have have typo in your python file. 您的python文件中也有错字。 response is missing the first 's': 响应缺少第一个“ s”:

self.reponse.headers['Content-Type'] = 'text/plain'

should be 应该

self.response.headers['Content-Type'] = 'text/plain'

You have a problem in app.yaml file in the handlers section: 您在处理程序部分的app.yaml文件中存在问题:

Yours: 您的:

application: testprogram
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: main.py

but you should have: 但您应该具有:

application: testprogram
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /.*
  script: main.app

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有多个 response.out.write 语句的 Python 方法 - Python method with multiple response.out.write statements 附加到response.out.write的不需要的模板代码 - Unwanted template code attached to response.out.write Google App Engine本地主机问题 - Google App Engine Local Host Issue 无法将本地主机:8000 与 Google App Engine 绑定 - Unable to bind local host:8000 with Google App Engine 使用Python的Google App Engine中的JSON响应 - JSON response in Google App Engine with Python python google-cloud-sdk/bin/dev_appserver.py --host **.22*.74* --port 8000 ./out/app_engine/ - python google-cloud-sdk/bin/dev_appserver.py --host **.22*.74* --port 8000 ./out/app_engine/ 如何将本地Google App Engine Python数据存储区复制到本地Google App Engine Java数据存储区? - How do I copy local Google App Engine Python datastore to local Google App Engine Java datastore? 无法在Google App Engine和Python上显示来自云存储的图像 - Trouble displaying image from cloud storage on Google App Engine, Python Google App Engine(python)-通过python脚本连接到本地数据存储 - Google App Engine (python) - Connecting to local datastore via python script 如何将 Python 3 与 Google App Engine 的本地开发服务器一起使用 - How to use Python 3 with Google App Engine's Local Development Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM