18 lines
534 B
Python
18 lines
534 B
Python
from django.conf.urls import url
|
|
|
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
|
from channels.sessions import SessionMiddlewareStack
|
|
from django.core.asgi import get_asgi_application
|
|
|
|
from .views.ws_api import CustomConsumer
|
|
|
|
application = ProtocolTypeRouter({
|
|
# Django's ASGI application to handle traditional HTTP requests
|
|
"http": get_asgi_application(),
|
|
|
|
# WebSocket send handler
|
|
"websocket": SessionMiddlewareStack(URLRouter([
|
|
url(r"^test-ws-endpoint/$", CustomConsumer.as_asgi()),
|
|
]))
|
|
})
|