summaryrefslogtreecommitdiff
path: root/tests/fileserve_async.py
blob: 2619f5ab6791805d29afd9bc1734d8b734f0748c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import sys
import mimetypes

basedir = sys.argv[1]
mimetypes.init()


def application(environ, start_response):

    filename = basedir + environ['PATH_INFO']
    (content_type, encoding) = mimetypes.guess_type(filename)
    if not content_type:
        content_type = 'text/plain'

    start_response('200 OK', [('Content-Type', content_type)])
    fd = open(filename)
    yield environ['wsgi.file_wrapper'](fd, 32*1024)