2025-03-18 08:46:50 +08:00

33 lines
985 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
ASGI config for application 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
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
django.setup()
from django.core.asgi import get_asgi_application
from utils.middleware import JwtAuthMiddleware
from channels.routing import ProtocolTypeRouter, URLRouter
from apps.lywebsocket.routing import websocket_urlpatterns
# application = get_asgi_application()
application = ProtocolTypeRouter({
"http": get_asgi_application(),# 也可以不需要此项普通的HTTP请求不需要我们手动在这里添加框架会自动加载
"websocket": JwtAuthMiddleware(
# 多个url合并一起使用多个子路由列表相加:a+b
URLRouter(
websocket_urlpatterns
)
),
})