I am writing an app on GAE and I have a URL that will always return XML and set the Content-Type to "text/xml; charset=utf-8"
.
I am using the built in webapp framework and using the following code to set content type and return XML in the web handler:
self.response.headers.add_header('Content-Type',"text/xml; charset=utf-8")
self.response.out.write(template.render("my_xml",{"key1":"val1"}))
This works fine on the local development environment but once I deploy to the Google servers the content type is always set to "text/html; charset=utf-8"
.
How do I make sure that correct Content-Type
is set once it runs on the Google servers?
Use self.response.headers['Content-Type'] = "text/xml; charset=utf-8"
, so that you override the content-type rather than adding another homonymous header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With