asgi.py 619 B

12345678910111213141516171819
  1. import os
  2. from django.core.asgi import get_asgi_application
  3. from utils.websocket import websocket_application
  4. from asgihandler.core import ASGIHandler
  5. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'greaterwms.settings')
  6. http_application = get_asgi_application()
  7. async def application(scope, receive, send):
  8. if scope['type'] in ['http', 'https']:
  9. ASGIHandler.asgi_get_handler(scope)
  10. await http_application(scope, receive, send)
  11. elif scope['type'] in ['websocket']:
  12. await websocket_application(scope, receive, send)
  13. else:
  14. raise Exception('Unknown Type' + scope['type'])