【发布时间】:2017-08-29 16:59:18
【问题描述】:
我正在学习在 GAE 中使用 cookie。每次,我打开 localhost:8080,一个名为“下载”的文件,没有任何扩展下载。当我在记事本中打开它时,它有“你来过这里 0 次”。因此,它不是将内容写入 HTML,而是下载包含内容的文件。
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'type/plain'
visits = self.request.cookies.get('visits', 0)
self.response.out.write("You've been here %s times." % visits)
app = webapp2.WSGIApplication([('/', MainPage),], debug = True)
谁能告诉我为什么会发生这种情况,我该如何避免?
【问题讨论】:
标签: python google-app-engine webapp2