From 457d171cd48bf4809d3809fc9511836795972bf5 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 6 Mar 2019 21:20:39 +0100 Subject: Improve the display of supported formats - Show the extension instead of the mimetype - Sort the results --- main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'main.py') diff --git a/main.py b/main.py index 033d8b6..1a99ad4 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ import os import hashlib import hmac +import mimetypes as mtype from libmat2 import parser_factory @@ -60,7 +61,9 @@ def upload_file(): mimetypes = set() for parser in parser_factory._get_parsers(): - mimetypes = mimetypes | parser.mimetypes + mimetypes |= set(map(mtype.guess_extension, parser.mimetypes)) + # since `guess_extension` might return `None`, we need to filter it out + mimetypes = sorted(filter(None, mimetypes)) if request.method == 'POST': if 'file' not in request.files: # check if the post request has the file part -- cgit v1.3