Im trying to send an excel file back to the user's browser in flask. The excel file is created with openpyxl.
@app.route('/test', methods=['GET', 'POST'])
def test():
if request.method == 'GET':
...
buf = BytesIO()
wb.save(buf)
buf.seek(0)
resp = make_response(buf)
resp.headers["Content-Disposition"] = "attachment; filename=export.xlsx"
resp.headers["Content-Type"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
return resp
Im getting the following error:
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a BytesIO.
How can i do this, without using BytesIO?
Many thanks in advance