From a188df3ae359ab770aac85d19d23739286ef6d41 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Tue, 9 Jun 2026 22:53:50 +0200 Subject: Initial commit --- chat/asgi.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 chat/asgi.py (limited to 'chat/asgi.py') diff --git a/chat/asgi.py b/chat/asgi.py new file mode 100644 index 0000000..247393e --- /dev/null +++ b/chat/asgi.py @@ -0,0 +1,28 @@ +""" +ASGI config for chat project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/ +""" + +import os + +from channels.auth import AuthMiddlewareStack +from channels.routing import ProtocolTypeRouter, URLRouter +from channels.security.websocket import AllowedHostsOriginValidator +from django.core.asgi import get_asgi_application + +from chat.routing import websocket_urlpatterns + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chat.settings') + +application = ProtocolTypeRouter( + { + "http": get_asgi_application(), + "websocket": AllowedHostsOriginValidator( + AuthMiddlewareStack(URLRouter(websocket_urlpatterns)) + ), + } +) -- cgit v1.2.3