Skip to content

Commit 54875e9

Browse files
committed
Direct passthrough is counter productive
1 parent 81b4271 commit 54875e9

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

docs/patterns/streaming.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ Basic Usage
1313

1414
This is a basic view function that generates a lot of CSV data on the fly.
1515
The trick is to have an inner function that uses a generator to generate
16-
data and to then invoke that function and pass it to a response object
17-
that has the ``direct_passthrough`` flag set. This flag is used to inform
18-
the system that data is generated on the fly and should be passed through
19-
without buffering::
16+
data and to then invoke that function and pass it to a response object::
2017

2118
from flask import Response
2219

@@ -25,8 +22,7 @@ without buffering::
2522
def generate():
2623
for row in iter_all_rows():
2724
yield ','.join(row) + '\n'
28-
return Response(generate(), direct_passthrough=True,
29-
mimetype='text/csv')
25+
return Response(generate(), mimetype='text/csv')
3026

3127
Each ``yield`` expression is directly sent to the browser. Now though
3228
that some WSGI middlewares might break streaming, so be careful there in
@@ -51,8 +47,7 @@ quite uncommon, but you can easily do it yourself::
5147
@app.route('/my-large-page.html')
5248
def render_large_template():
5349
rows = iter_all_rows()
54-
return Response(stream_template('the_template.html', rows=rows),
55-
direct_passthrough=True)
50+
return Response(stream_template('the_template.html', rows=rows))
5651

5752
The trick here is to get the template object from the Jinja2 environment
5853
on the application and to call :meth:`~jinja2.Template.stream` instead of

0 commit comments

Comments
 (0)