I have a Pandas framework in my Flask application that I want to return as a CSV file.
return Response(df.to_csv())
The problem is that the output appears in the browser instead of downloading as a separate file. How to change this?
I tried the following, but it just gave an empty output.
response = make_response(df.to_csv()) response.headers['Content-Type'] = 'text/csv' return Response(response)
source share