homelog/homelog/asgi.py

23 lines
637 B
Python

import os
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
import homelog.routing
from channels.routing import ChannelNameRouter
from .mqtt_consumer import MqttConsumer
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'homelog.settings')
django_application = get_asgi_application()
application = ProtocolTypeRouter({
"http": get_asgi_application(),
"websocket": AuthMiddlewareStack(URLRouter(homelog.routing.websocket_urlpatterns)),
"channel": ChannelNameRouter({
"mqtt": MqttConsumer.as_asgi(),
})
})