""" ASGI config for {{ cookiecutter.project_name }} 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/dev/howto/deployment/asgi/ """ import os import sys from pathlib import Path from django.core.asgi import get_asgi_application from .websocket import websocket_application # This allows easy placement of apps within the interior # {{ cookiecutter.project_slug }} directory. app_path = Path(__file__).parents[1].resolve() sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks # if running multiple sites in the same mod_wsgi process. To fix this, use # mod_wsgi daemon mode with each site in its own daemon process, or use # os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.production" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") # This application object is used by any ASGI server configured to use this # file. This includes Django's development server, if the ASGI_APPLICATION # setting points here. django_application = get_asgi_application() # Apply ASGI middleware here. # from helloworld.asgi import HelloWorldApplication # application = HelloWorldApplication(application) async def application(scope, receive, send): if scope["type"] == "http": await django_application(scope, receive, send) elif scope["type"] == "websocket": await websocket_application(scope, receive, send) else: raise NotImplementedError(f"Unknown scope type {scope['type']}")