[英]In GAE, file 'download' keeps downloading instead of writing content to HTML
I'm learning to use cookies in GAE. 我正在学习在GAE中使用Cookie。 Every time, I open localhost:8080, a file named just 'download' without any extension downloads. 每次,我打开localhost:8080,一个名为“ download”的文件,没有任何扩展名下载。 When I open it in notepad, it has "You've been here 0 times." 当我在记事本中打开它时,它显示“您去过这里0次”。 So, instead of writing the content to HTML it downloads a file with the content. 因此,与其将内容写入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)
Can please anyone tell me why this is happening and how can I avoid it? 能否请任何人告诉我为什么会这样以及如何避免呢?
正确的“内容类型”是“文本/纯文本”。
self.response.headers['Content-Type'] = 'text/plain'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.