K
K
kibastos2019-08-26 14:05:19
Python
kibastos, 2019-08-26 14:05:19

How to change mimetype for static xmltv.xml.gz file on local flask?

Faced a small problem on flask. The TV guide file 'xmltv.xml.gz' is located in the 'static' folder and is rummaged through the local network to home devices. Not all applications can read this file due to the headers that flask returns. The local server returns the file as 'Content-Type': 'text/xml; charset=utf-8'. Any sites on the Internet give files of this type as 'Content-Type': 'application/octet-stream'. Tell me where to correct the mimetype on flask so that the server gives the correct headers for compressed TV guide files and is such editing possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pcdesign, 2019-08-26
@pcdesign

There is an option to use send_file You can use make_response

from flask import make_response
r = make_response(content)
r.mimetype = 'application/octet-stream'
return r

Well, or use send_file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question