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