@@ -13,10 +13,7 @@ Basic Usage
13
13
14
14
This is a basic view function that generates a lot of CSV data on the fly.
15
15
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::
20
17
21
18
from flask import Response
22
19
@@ -25,8 +22,7 @@ without buffering::
25
22
def generate():
26
23
for row in iter_all_rows():
27
24
yield ','.join(row) + '\n'
28
- return Response(generate(), direct_passthrough=True,
29
- mimetype='text/csv')
25
+ return Response(generate(), mimetype='text/csv')
30
26
31
27
Each ``yield `` expression is directly sent to the browser. Now though
32
28
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::
51
47
@app.route('/my-large-page.html')
52
48
def render_large_template():
53
49
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))
56
51
57
52
The trick here is to get the template object from the Jinja2 environment
58
53
on the application and to call :meth: `~jinja2.Template.stream ` instead of
0 commit comments