mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-10 19:57:09 +03:00
6301fcc603
* Update black from 23.12.1 to 24.1.0 * Update black from 23.12.1 to 24.1.0 * Update black pre-commit hooks * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix a few styling issues for black v24 --------- Co-authored-by: Bruno Alla <alla.brunoo@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
"""
|
|
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
|
|
|
|
# This allows easy placement of apps within the interior
|
|
# {{ cookiecutter.project_slug }} directory.
|
|
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
|
|
sys.path.append(str(BASE_DIR / "{{ cookiecutter.project_slug }}"))
|
|
|
|
# If DJANGO_SETTINGS_MODULE is unset, default to the local settings
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
|
|
|
# This application object is used by any ASGI server configured to use this file.
|
|
django_application = get_asgi_application()
|
|
# Apply ASGI middleware here.
|
|
# from helloworld.asgi import HelloWorldApplication
|
|
# application = HelloWorldApplication(application)
|
|
|
|
# Import websocket application here, so apps from django_application are loaded first
|
|
from config.websocket import websocket_application # noqa isort:skip
|
|
|
|
|
|
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']}")
|