Files
uwsgi/tests/fileserve_async.py
T
2012-03-07 15:06:38 +01:00

18 lines
403 B
Python

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,'r')
yield environ['wsgi.file_wrapper'](fd, 32*1024)