-
-
Save mieitza/4341f290e0dba9c6c53a5596779f4e94 to your computer and use it in GitHub Desktop.
#python #flask #pandas Using flask to return a csv response from a dataframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import StringIO | |
from flask import Flask, Response | |
@app.route('/some_dataframe.csv') | |
def output_dataframe_csv(): | |
output = StringIO.StringIO() | |
some_dataframe.to_csv(output) | |
return Response(output.getvalue(), mimetype="text/csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment