How do I customize the content type of the response in the flask?
I want to be able to return something other than application / json ie kml.
I have the following:
@api.representation('application/vnd.google-earth.kml+xml') def kml(data): return Response(data, mimetype='application/vnd.google-earth.kml+xml') class mykml(restful.Resource): def get(self): r = requests.get("http://myurl/kml") # This retrieves a .kml file response = make_response(r.content) response.headers['Content-Type'] = "application/vnd.google-earth.kml+xml" return response
Why is this still returning app / json? Also, if I have different formats, can I dynamically change the Content-Type for the user in the mykml class without a decorator?
from flask import Flask, request, Response, session,make_response
source to share
No one has answered this question yet
See similar questions: