27 lines
815 B
Python
27 lines
815 B
Python
"""
|
|
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
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
|
|
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
|
|
|
|
from application.websocketConfig import websocket_application
|
|
|
|
http_application = get_asgi_application()
|
|
|
|
async def application(scope,receive,send):
|
|
if scope['type'] == 'http':
|
|
await http_application(scope, receive, send)
|
|
elif scope['type'] == 'websocket':
|
|
await websocket_application(scope, receive, send)
|
|
else:
|
|
raise Exception("未知的scope类型,"+ scope['type']) |