From d07b313e8959a514797f9f2d249d6cbf00a27573 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 16 Dec 2018 21:47:25 +0100 Subject: Supported types are now directly provided by mat2 --- main.py | 5 +++++ tests.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/main.py b/main.py index 5db7cb3..fb29a44 100644 --- a/main.py +++ b/main.py @@ -36,6 +36,11 @@ def download_file(filename:str): @app.route('/', methods=['GET', 'POST']) def upload_file(): + mimetypes = set() + for parser in parser_factory._get_parsers(): + mimetypes = mimetypes | parser.mimetypes + mimetypes = ', '.join(mimetypes) + if request.method == 'POST': if 'file' not in request.files: # check if the post request has the file part flash('No file part') diff --git a/tests.py b/tests.py index 456cb4d..8ce7d7e 100644 --- a/tests.py +++ b/tests.py @@ -19,6 +19,11 @@ class FlaskrTestCase(unittest.TestCase): rv = self.app.get('/') self.assertIn(b'mat2-web', rv.data) + def test_check_mimetypes(self): + rv = self.app.get('/') + self.assertIn(b'application/zip', rv.data) + self.assertIn(b'audio/x-flac', rv.data) + def test_get_download_dangerous_file(self): rv = self.app.get('/download/\..\filename') self.assertEqual(rv.status_code, 302) -- cgit v1.3