tests: Use different workaround for mimetypes issue

This commit is contained in:
Florian Bruhin 2021-01-27 18:47:44 +01:00
parent dc5d366642
commit fe5738119a
1 changed files with 6 additions and 6 deletions

View File

@ -30,6 +30,7 @@ import sys
import json
import time
import threading
import mimetypes
import pathlib
from http import HTTPStatus
@ -60,12 +61,6 @@ def send_data(path):
data_dir = END2END_DIR / 'data'
if (data_dir / path).is_dir():
path += '/index.html'
if path == 'service-worker/worker.js':
# For some reason, Flask returns this with a text/plain mimetype on GitHub
# Actions with Windows?!
flask.send_file(path, mimetype='text/javascript')
return flask.send_from_directory(data_dir, path)
@ -330,6 +325,11 @@ def main():
app.template_folder = END2END_DIR / 'templates'
assert app.template_folder.is_dir(), app.template_folder
if mimetypes.guess_type('worker.js')[0] == 'text/plain':
# WORKAROUND for https://github.com/pallets/flask/issues/1045
# Needed for Windows on GitHub Actions for some reason...
mimetypes.add_type('application/javascript', '.js')
port = int(sys.argv[1])
server = WSGIServer(('127.0.0.1', port), app)
server.start()