返回一个数据帧作为结果Flask



我使用烧瓶。我想返回一个数据帧作为结果。但我犯了这个错误。

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 DataFrame. 

将响应标头设置为text/csv

resp.headers["Content-Disposition"] = "attachment; filename=export.csv"
resp.headers["Content-Type"] = "text/csv"
return resp

最新更新