summaryrefslogtreecommitdiffstats
path: root/chat/asgi.py
diff options
context:
space:
mode:
Diffstat (limited to 'chat/asgi.py')
-rw-r--r--chat/asgi.py28
1 files changed, 28 insertions, 0 deletions
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 @@
1"""
2ASGI config for chat project.
3
4It exposes the ASGI callable as a module-level variable named ``application``.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
8"""
9
10import os
11
12from channels.auth import AuthMiddlewareStack
13from channels.routing import ProtocolTypeRouter, URLRouter
14from channels.security.websocket import AllowedHostsOriginValidator
15from django.core.asgi import get_asgi_application
16
17from chat.routing import websocket_urlpatterns
18
19os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chat.settings')
20
21application = ProtocolTypeRouter(
22 {
23 "http": get_asgi_application(),
24 "websocket": AllowedHostsOriginValidator(
25 AuthMiddlewareStack(URLRouter(websocket_urlpatterns))
26 ),
27 }
28)