2025-10-21 11:10:17 +02:00

24 lines
735 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
# Add repository root so 'project' package is importable regardless of CWD.
repo_root = Path(__file__).resolve().parent.parent.parent
if str(repo_root) not in sys.path:
sys.path.insert(0, str(repo_root))
os.environ['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)),
})