2025-10-15 17:41:05 +02:00

23 lines
668 B
Python

import os
import sys
from pathlib import Path
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
project_dir = Path(__file__).resolve().parent.parent
if str(project_dir) not in sys.path:
sys.path.insert(0, str(project_dir))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.config.settings')
http_app = get_asgi_application()
# Lazy import after Django setup
from project.config import routing # noqa: E402
application = ProtocolTypeRouter({
'http': http_app,
'websocket': AuthMiddlewareStack(URLRouter(routing.websocket_urlpatterns)),
})