[英]In GAE, file 'download' keeps downloading instead of writing content to HTML
我正在学习在GAE中使用Cookie。 每次,我打开localhost:8080,一个名为“ download”的文件,没有任何扩展名下载。 当我在记事本中打开它时,它显示“您去过这里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)
能否请任何人告诉我为什么会这样以及如何避免呢?
正确的“内容类型”是“文本/纯文本”。
self.response.headers['Content-Type'] = 'text/plain'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.