mirror of
https://github.com/tanrax/slack-clone-using-HTML-over-the-Wire.git
synced 2026-08-14 17:53:13 +02:00
29 lines
760 B
Python
29 lines
760 B
Python
# project_template/asgi.py
|
|
import os
|
|
import django
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_template.settings")
|
|
django.setup()
|
|
|
|
from django.core.asgi import get_asgi_application
|
|
from channels.auth import AuthMiddlewareStack
|
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
|
from django.urls import re_path
|
|
from app.chat.consumers import ChatConsumer
|
|
|
|
|
|
application = ProtocolTypeRouter(
|
|
{
|
|
# Django's ASGI application to handle traditional HTTP requests
|
|
"http": get_asgi_application(),
|
|
# WebSocket handler
|
|
"websocket": AuthMiddlewareStack(
|
|
URLRouter(
|
|
[
|
|
re_path(r"^ws/chat/$", ChatConsumer.as_asgi()),
|
|
]
|
|
)
|
|
),
|
|
}
|
|
)
|