django-vue-admin/backend/application/asgi.py

28 lines
826 B
Python
Raw Normal View History

2022-04-05 05:22:26 +00:00
"""
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
from django.core.asgi import get_asgi_application
2022-11-17 02:53:47 +00:00
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
2022-04-05 05:22:26 +00:00
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
2022-05-19 03:17:48 +00:00
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
2022-04-05 05:22:26 +00:00
2022-11-17 02:53:47 +00:00
from application.routing import websocket_urlpatterns
2022-08-14 11:11:21 +00:00
http_application = get_asgi_application()
2022-11-17 02:53:47 +00:00
application = ProtocolTypeRouter({
"http":http_application,
'websocket': AuthMiddlewareStack(
URLRouter(
websocket_urlpatterns #指明路由文件是devops/routing.py
)
),
})