Use itemtypes to figure out the mime type in HTTP mode
This commit is contained in:
parent
53a0ef3daf
commit
0867a6ef40
6
neomi.py
6
neomi.py
|
@ -411,6 +411,7 @@ def read_infofile(file_path):
|
||||||
|
|
||||||
# TODO: Read from file
|
# TODO: Read from file
|
||||||
extension_mimetypes = {'.txt': 'text/plain', '.text': 'text/plain', '.log': 'text/plain', '.html': 'text/html'}
|
extension_mimetypes = {'.txt': 'text/plain', '.text': 'text/plain', '.log': 'text/plain', '.html': 'text/html'}
|
||||||
|
itemtype_mimetypes = {'0': 'text/plain', '1': 'text/x-gophermap', 'h': 'text/html'}
|
||||||
|
|
||||||
mimetype_cache = {}
|
mimetype_cache = {}
|
||||||
mimetype_cache_lock = threading.Lock()
|
mimetype_cache_lock = threading.Lock()
|
||||||
|
@ -726,7 +727,10 @@ class Serve(threading.Thread):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
full_path = get_full_path(path, config = self.config)
|
full_path = get_full_path(path, config = self.config)
|
||||||
mimetype = get_mimetype(full_path, config = self.config)
|
if protocol == Protocol.http and itemtype in itemtype_mimetypes:
|
||||||
|
mimetype = itemtype_mimetypes[itemtype]
|
||||||
|
else:
|
||||||
|
mimetype = get_mimetype(full_path, config = self.config)
|
||||||
file = get_file(full_path, config = self.config)
|
file = get_file(full_path, config = self.config)
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
|
Loading…
Reference in New Issue