voice-changer/server/sio/MMVC_SocketIOApp.py

42 lines
1.6 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-03-08 03:48:50 +03:00
from const import getFrontendPath
2022-12-31 12:27:38 +03:00
2023-02-16 21:47:43 +03:00
2022-12-31 12:27:38 +03:00
class MMVC_SocketIOApp():
@classmethod
2023-02-16 21:47:43 +03:00
def get_instance(cls, app_fastapi, voiceChangerManager: VoiceChangerManager):
2022-12-31 12:27:38 +03:00
if not hasattr(cls, "_instance"):
sio = MMVC_SocketIOServer.get_instance(voiceChangerManager)
app_socketio = socketio.ASGIApp(
2023-02-16 21:47:43 +03:00
sio,
other_asgi_app=app_fastapi,
static_files={
'/assets/icons/github.svg': {
2023-03-08 03:48:50 +03:00
'filename': f'{getFrontendPath()}/assets/icons/github.svg',
2023-02-16 21:47:43 +03:00
'content_type': 'image/svg+xml'
},
'/assets/icons/help-circle.svg': {
2023-03-08 03:48:50 +03:00
'filename': f'{getFrontendPath()}/assets/icons/help-circle.svg',
2023-02-16 21:47:43 +03:00
'content_type': 'image/svg+xml'
},
'/assets/icons/tool.svg': {
'filename': f'{getFrontendPath()}/assets/icons/tool.svg',
'content_type': 'image/svg+xml'
},
2023-02-16 21:47:43 +03:00
'/buymeacoffee.png': {
2023-03-08 03:48:50 +03:00
'filename': f'{getFrontendPath()}/assets/buymeacoffee.png',
2023-02-16 21:47:43 +03:00
'content_type': 'image/png'
},
2023-03-08 03:48:50 +03:00
'': f'{getFrontendPath()}',
'/': f'{getFrontendPath()}/index.html',
2023-02-16 21:47:43 +03:00
}
)
2022-12-31 12:27:38 +03:00
cls._instance = app_socketio
return cls._instance
return cls._instance