2023-03-28 00:26:49 +03:00
|
|
|
import os
|
|
|
|
|
|
|
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
2023-07-10 03:13:42 +03:00
|
|
|
from django.conf import settings
|
2023-03-28 00:26:49 +03:00
|
|
|
from django.core.asgi import get_asgi_application
|
|
|
|
|
2023-11-29 17:36:33 +03:00
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
|
|
|
# Initialize Django ASGI application early to ensure the AppRegistry
|
|
|
|
# is populated before importing code that may import ORM models.
|
|
|
|
django_asgi_app = get_asgi_application()
|
|
|
|
|
|
|
|
|
|
|
|
from akarpov.common.channels import HeaderAuthMiddleware # noqa
|
|
|
|
from config import routing # noqa
|
2023-03-28 00:26:49 +03:00
|
|
|
|
2023-07-10 03:13:42 +03:00
|
|
|
if settings.DEBUG:
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
|
|
|
else:
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
|
2023-03-28 00:26:49 +03:00
|
|
|
|
|
|
|
application = ProtocolTypeRouter(
|
|
|
|
{
|
2023-11-29 17:36:33 +03:00
|
|
|
"http": django_asgi_app,
|
2023-03-28 00:26:49 +03:00
|
|
|
"websocket": HeaderAuthMiddleware(URLRouter(routing.websocket_urlpatterns)),
|
|
|
|
}
|
|
|
|
)
|