mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2026-02-04 03:30:26 +01:00
40 lines
1023 B
Python
40 lines
1023 B
Python
# /pong/asgi.py
|
|
|
|
"""
|
|
ASGI config for pong 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/3.2/howto/deployment/asgi/
|
|
"""
|
|
|
|
import os
|
|
import django
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logger.debug("Setting default DJANGO_SETTINGS_MODULE to 'pong.settings'")
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pong.settings')
|
|
|
|
logger.debug("Initializing Django setup")
|
|
django.setup()
|
|
|
|
from django.core.asgi import get_asgi_application
|
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
|
from channels.auth import AuthMiddlewareStack
|
|
import pong.game.routing
|
|
|
|
logger.debug("Configuring ProtocolTypeRouter")
|
|
application = ProtocolTypeRouter({
|
|
"http": get_asgi_application(),
|
|
"websocket": AuthMiddlewareStack(
|
|
URLRouter(
|
|
pong.game.routing.websocket_urlpatterns
|
|
)
|
|
),
|
|
})
|
|
|
|
logger.info("ASGI application configurée et prête à accepter les connexions")
|