[Flask] 대용량 데이터를 클라이언트로 전송하는 방법
출처: http://flask.pocoo.org/docs/0.12/patterns/streaming/
Basic Usage¶
This is a basic view function that generates a lot of CSV data on the fly. The trick is to have an inner function that uses a generator to generate data and to then invoke that function and pass it to a response object:
from flask import Response @app . route ( '/large.csv' ) def generate_large_csv (): def generate (): for row in iter_all_rows (): yield ',' . join ( row ) + '
' return Response ( generate (), mimetype = 'text/csv' )
from http://dev4u.tistory.com/948 by ccl(A) rewrite - 2020-03-06 21:54:28
댓글
댓글 쓰기