Skip to content

Instantly share code, notes, and snippets.

@mieitza
Forked from c0ldlimit/gist:5164171
Created January 3, 2018 15:06
Show Gist options
  • Save mieitza/4341f290e0dba9c6c53a5596779f4e94 to your computer and use it in GitHub Desktop.
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
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