server accepts websocket connection

This commit is contained in:
2024-08-21 20:05:14 +02:00
parent 1a4c919473
commit 1eb7da97d2
9 changed files with 64 additions and 19 deletions

View File

@ -9,8 +9,17 @@ https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
import os
from channels.routing import ProtocolTypeRouter, URLRouter
from django.urls import path
from django.core.asgi import get_asgi_application
from .websocket import WebsocketHandler
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
application = get_asgi_application()
django = get_asgi_application()
application = ProtocolTypeRouter({
"http": django,
"websocket":URLRouter({path("ws",WebsocketHandler.as_asgi())})
})