簡體   English   中英

使用python編寫的response.out.write,Google App引擎未顯示在本地主機上

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

我的Yaml文件:

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

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

我的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)

從服務器:

$ 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 -

服務器斷了。 本地主機已啟動。 但是什么都沒有寫出來。 我正在上大學課程,所以我才剛剛開始。 掛斷電話可能是什么。 正在檢查文檔,但仍然丟失。

.yaml文件中,將路由處理程序指向main.app(而不是main.py)。

您的python文件中也有錯字。 響應缺少第一個“ s”:

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

應該

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

您在處理程序部分的app.yaml文件中存在問題:

您的:

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

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

但您應該具有:

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM