""" 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 whitenoise import WhiteNoise 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 from django.contrib.staticfiles.handlers import ASGIStaticFilesHandler from pathlib import Path # application = ProtocolTypeRouter( # { # "http": get_asgi_application(), # # "websocket": AuthMiddlewareStack(URLRouter(routing.websocket_urlpatterns)), # } # ) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "car_inventory.settings") # django.setup() # BASE_DIR = Path(__file__).resolve().parent.parent app = get_asgi_application() # app = WhiteNoise(app, root=str(BASE_DIR / 'staticfiles')) application = ProtocolTypeRouter( { "http": AuthMiddlewareStack( URLRouter( [ path("sse/notifications/", NotificationSSEApp()), re_path( r"", app ), ] ) ), } ) # if django.conf.settings.DEBUG: # application = ASGIStaticFilesHandler(app)