voice-changer/server/sio/MMVC_SocketIOApp.py

35 lines
1.2 KiB
Python
Raw Normal View History

2022-12-31 12:27:38 +03:00
import socketio
from sio.MMVC_SocketIOServer import MMVC_SocketIOServer
from voice_changer.VoiceChangerManager import VoiceChangerManager
2023-01-05 19:37:29 +03:00
from const import frontend_path
2022-12-31 12:27:38 +03:00
class MMVC_SocketIOApp():
@classmethod
def get_instance(cls, app_fastapi, voiceChangerManager:VoiceChangerManager):
if not hasattr(cls, "_instance"):
sio = MMVC_SocketIOServer.get_instance(voiceChangerManager)
app_socketio = socketio.ASGIApp(
sio,
other_asgi_app=app_fastapi,
static_files={
'/assets/icons/github.svg': {
2023-01-05 19:37:29 +03:00
'filename': f'{frontend_path}/assets/icons/github.svg',
2022-12-31 12:27:38 +03:00
'content_type': 'image/svg+xml'
},
2023-01-14 12:56:32 +03:00
'/assets/icons/help-circle.svg': {
'filename': f'{frontend_path}/assets/icons/help-circle.svg',
'content_type': 'image/svg+xml'
},
2023-01-05 19:37:29 +03:00
'': f'{frontend_path}',
'/': f'{frontend_path}/index.html',
2022-12-31 12:27:38 +03:00
}
)
cls._instance = app_socketio
return cls._instance
return cls._instance