2025-08-27 13:04:41 +03:00

49 lines
1.2 KiB
Python

"""
ASGI config for car_inventory 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/
"""
# asgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "car_inventory.settings")
import django
django.setup()
from django.urls import path
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from api import routing
from inventory.notifications.sse import NotificationSSEApp
from django.urls import re_path
from django.core.asgi import get_asgi_application
# application = ProtocolTypeRouter(
# {
# "http": get_asgi_application(),
# # "websocket": AuthMiddlewareStack(URLRouter(routing.websocket_urlpatterns)),
# }
# )
application = ProtocolTypeRouter(
{
"http": AuthMiddlewareStack(
URLRouter(
[
path("sse/notifications/", NotificationSSEApp()),
re_path(
r"", get_asgi_application()
), # All other routes go to Django
]
)
),
}
)