Klaus Demo bjoern / 3ebf424
Added a test case Jonas Haag 8 years ago
1 changed file(s) with 21 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 import sys
1 import os
2 import bjoern
3
4 W = {
5 'callable-iterator' : lambda f, e: iter(lambda: f.read(64*1024), ''),
6 'xreadlines' : lambda f, e: f,
7 'filewrapper' : lambda f, env: env['wsgi.file_wrapper'](f)
8 }
9
10 F = len(sys.argv) > 1 and sys.argv[1] or 'README.rst'
11 W = len(sys.argv) > 2 and W[sys.argv[2]] or W['filewrapper']
12
13 def app(env, start_response):
14 f = open(F)
15 wrapped = W(f, env)
16 start_response('200 ok', [('Content-Length', str(os.path.getsize(F)))])
17 return wrapped
18
19 import bjoern
20 bjoern.run(app, '0.0.0.0', 8080)