0

I have a Flask method that gets url and returns the zip file's content. The content should be returned to the axios get method. Flask code:

zip_file = requests.get(url)
if zip_file.ok:
   return {
        'file': zip_file.content
  }

But it doesn't work, it fires exception 'TypeError(repr(o) + " is not JSON serializable").

How to fix it? I saw some solutions with coding-decoding but I'm not sure how to use it, especially after the axios request gets the response (I can't use the direct link because of security reasons).

mimic
  • 4,897
  • 7
  • 54
  • 93
  • The issue is coming from that it's being dumped into a JSON and the zip file that you have is not in a format that's understood. Try: https://stackoverflow.com/questions/51024276/python-stream-from-ftp-server-to-flask-server-for-downloading – mattsap May 06 '19 at 02:59
  • @mattsap Probably it's the reason but I still don't know how to solve it. Can you suggest some code? – mimic May 06 '19 at 03:10

0 Answers0