【发布时间】:2017-01-08 22:07:56
【问题描述】:
我的 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 -
服务器已启动。本地主机已启动。但是什么都没有写出来。我正在做udacitys课程,所以我才刚刚开始。挂机可能是什么。一直在检查文档,但仍然丢失。
【问题讨论】:
-
您在服务器日志中看到了什么?
-
编辑以包括现在
-
我厌倦了它,但它没有用。我正在遵循oreilly的指示。这是带有说明的网站:archive.oreilly.com/pub/a/web-services/excerpts/9780596800697/…
-
您的请求似乎处理得很好 - 代码 200。有点奇怪,因为您有一个错字:
self.reponse.headers而不是self.response.headers(但也许您已经修复了)。在您的浏览器上检查页面来源,可能只是显示不正确。 -
旁注:使用 webapp2 您可以直接使用
self.response.write而不是self.response.out.write(但两者都应该工作);同时删除的另一条评论很好——你想要python27而不是python,请参阅服务器日志中的第一个警告。
标签: python google-app-engine localhost yaml