Show More
@@ -197,18 +197,14 b' def staticfile(templatepath, directory, ' | |||
|
197 | 197 | directory = os.path.join(tp, b'static') |
|
198 | 198 | |
|
199 | 199 | fpath = os.path.join(*fname.split(b'/')) |
|
200 | ct = pycompat.sysbytes( | |
|
201 | mimetypes.guess_type(pycompat.fsdecode(fpath))[0] or r"text/plain" | |
|
202 | ) | |
|
200 | 203 | path = os.path.join(directory, fpath) |
|
201 | 204 | try: |
|
202 | 205 | os.stat(path) |
|
203 | ct = pycompat.sysbytes( | |
|
204 | mimetypes.guess_type(pycompat.fsdecode(fpath))[0] or r"text/plain" | |
|
205 | ) | |
|
206 | 206 | with open(path, b'rb') as fh: |
|
207 | 207 | data = fh.read() |
|
208 | ||
|
209 | res.headers[b'Content-Type'] = ct | |
|
210 | res.setbodybytes(data) | |
|
211 | return res | |
|
212 | 208 | except TypeError: |
|
213 | 209 | raise ErrorResponse(HTTP_SERVER_ERROR, b'illegal filename') |
|
214 | 210 | except OSError as err: |
@@ -219,6 +215,10 b' def staticfile(templatepath, directory, ' | |||
|
219 | 215 | HTTP_SERVER_ERROR, encoding.strtolocal(err.strerror) |
|
220 | 216 | ) |
|
221 | 217 | |
|
218 | res.headers[b'Content-Type'] = ct | |
|
219 | res.setbodybytes(data) | |
|
220 | return res | |
|
221 | ||
|
222 | 222 | |
|
223 | 223 | def paritygen(stripecount, offset=0): |
|
224 | 224 | """count parity of horizontal stripes for easier reading""" |
General Comments 0
You need to be logged in to leave comments.
Login now