usr bin env python import sys cgitb from mimetypes import guess_type f

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python
import sys, cgitb
from mimetypes import guess_type
from os import path, environ
cgitb.enable(format='txt')
fpath = path.join(environ['DOCUMENT_ROOT'],environ['REDIRECT_URL'])
if not path.exists(fpath):
print 'Content-Type: text/html\n\n<b>404 not found!</b>'
sys.exit('EX_OK')
size = path.getsize(fpath)
mtype = guess_type(fpath)[0]
print 'Content-Type: %s\nAccept-Ranges: bytes\nContent-Length: %s\n' % (size, mtype)
print open(fpath).read()