I'm learning to use cookies in GAE. Every time, I open localhost:8080, a file named just 'download' without any extension downloads. When I open it in notepad, it has "You've been here 0 times." So, instead of writing the content to HTML it downloads a file with the content.
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?
The correct 'Content-Type' is 'text/plain'.
self.response.headers['Content-Type'] = 'text/plain'