From 7aec66486186d5746782e79309b7d28d5993f14c Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Wed, 25 Oct 2017 13:29:34 -0700 Subject: [PATCH] Add 'chunked' demo page. --- quixote/demo/extras.ptl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/quixote/demo/extras.ptl b/quixote/demo/extras.ptl index a662a30..292e6ab 100644 --- a/quixote/demo/extras.ptl +++ b/quixote/demo/extras.ptl @@ -1,11 +1,14 @@ import os +from quixote import get_response from quixote.directory import Directory, Resolving from quixote.util import StaticDirectory from quixote.demo.integers import IntegerUI +from quixote.http_response import Stream + class ExtraDirectory(Resolving, Directory): - _q_exports = ["", "form", "src"] + _q_exports = ["", "form", "src", "chunked"] def _q_index [html] (self): """ @@ -24,6 +27,9 @@ class ExtraDirectory(Resolving, Directory): A Quixote form in action.
  • src/: A static directory published through Quixote. +
  • chunked: + A page on indeterminate length using chunked transfer + encoding. """ @@ -43,6 +49,14 @@ class ExtraDirectory(Resolving, Directory): def upload(self): return 'upload demo unfinished' + def chunked(self): + def gen_content(): + yield 'The server does not know how long this will be.\n' + for i in range(30): + yield 'line %d\n' % i + get_response().set_content_type('text/plain') + return Stream(gen_content()) + import quixote src = StaticDirectory(os.path.dirname(quixote.__file__), list_directory=True)