mirror of
https://0xacab.org/jvoisin/mat2-web.git
synced 2025-02-24 00:59:59 -05:00
Supported types are now directly provided by mat2
This commit is contained in:
parent
5ce3db7e82
commit
d07b313e89
5
main.py
5
main.py
@ -36,6 +36,11 @@ def download_file(filename:str):
|
|||||||
|
|
||||||
@app.route('/', methods=['GET', 'POST'])
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
def upload_file():
|
def upload_file():
|
||||||
|
mimetypes = set()
|
||||||
|
for parser in parser_factory._get_parsers():
|
||||||
|
mimetypes = mimetypes | parser.mimetypes
|
||||||
|
mimetypes = ', '.join(mimetypes)
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if 'file' not in request.files: # check if the post request has the file part
|
if 'file' not in request.files: # check if the post request has the file part
|
||||||
flash('No file part')
|
flash('No file part')
|
||||||
|
5
tests.py
5
tests.py
@ -19,6 +19,11 @@ class FlaskrTestCase(unittest.TestCase):
|
|||||||
rv = self.app.get('/')
|
rv = self.app.get('/')
|
||||||
self.assertIn(b'mat2-web', rv.data)
|
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):
|
def test_get_download_dangerous_file(self):
|
||||||
rv = self.app.get('/download/\..\filename')
|
rv = self.app.get('/download/\..\filename')
|
||||||
self.assertEqual(rv.status_code, 302)
|
self.assertEqual(rv.status_code, 302)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user