Browse Source

fix wrong Content-Type

master^2
lilydjwg 1 year ago
parent
commit
415c741727
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      main.py

+ 8
- 0
main.py View File

@ -32,6 +32,11 @@ RISKY_TYPES = [
]
@lru_cache()
def guess_mime_using_file_p(path):
with open(path, 'rb') as f:
data = f.read()
return guess_mime_using_file(data)
def guess_mime_using_file(content):
result = subprocess.check_output(
['file', '-i', '-'],
@ -60,6 +65,9 @@ def qrencode(s):
return subprocess.check_output(
['qrencode', '-t', 'UTF8', s]).decode()
# for StaticFileHandler
mimetypes.guess_type = guess_mime_using_file_p
def guess_extension(ftype):
if ftype == 'application/octet-stream':
return '.bin'


Loading…
Cancel
Save