|
@@ -1,3 +1,4 @@
|
|
|
|
+from glob import glob
|
|
from os.path import exists
|
|
from os.path import exists
|
|
|
|
|
|
import eventlet
|
|
import eventlet
|
|
@@ -10,17 +11,19 @@ from pycs.frontend.FileProvider import FileProvider
|
|
class WebServer:
|
|
class WebServer:
|
|
def __init__(self, app_status: ApplicationStatus):
|
|
def __init__(self, app_status: ApplicationStatus):
|
|
# initialize web server
|
|
# initialize web server
|
|
- # TODO svg files need the correct mime type to be displayed correctly
|
|
|
|
if exists('webui/index.html'):
|
|
if exists('webui/index.html'):
|
|
print('production build')
|
|
print('production build')
|
|
files = FileProvider(app_status)
|
|
files = FileProvider(app_status)
|
|
|
|
+
|
|
|
|
+ # find svg icons and add them as separate static files to
|
|
|
|
+ # set their correct mime type / content_type
|
|
|
|
+ static_files = {'/': 'webui/'}
|
|
|
|
+ for path in glob('webui/img/*.svg'):
|
|
|
|
+ path = path.replace('\\', '/')
|
|
|
|
+ static_files[path[5:]] = {'content_type': 'image/svg+xml', 'filename': path}
|
|
|
|
+
|
|
self.__sio = socketio.Server()
|
|
self.__sio = socketio.Server()
|
|
- self.__app = socketio.WSGIApp(self.__sio, files, static_files={'/': 'webui/'})
|
|
|
|
- elif exists('webui/dist/index.html'):
|
|
|
|
- print('production build')
|
|
|
|
- files = FileProvider(app_status)
|
|
|
|
- self.__sio = socketio.Server()
|
|
|
|
- self.__app = socketio.WSGIApp(self.__sio, files, static_files={'/': 'webui/dist/'})
|
|
|
|
|
|
+ self.__app = socketio.WSGIApp(self.__sio, files, static_files=static_files)
|
|
else:
|
|
else:
|
|
print('development build')
|
|
print('development build')
|
|
files = FileProvider(app_status, cors=True)
|
|
files = FileProvider(app_status, cors=True)
|