21 lines
553 B
Python
21 lines
553 B
Python
# -*- coding: utf-8 -*-
|
||
"""
|
||
ASGI 入口:HTTP (Django) + WebSocket (Channels)。
|
||
"""
|
||
import os
|
||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
|
||
|
||
import django # noqa: E402
|
||
django.setup() # noqa: E402
|
||
|
||
from channels.routing import ProtocolTypeRouter, URLRouter # noqa: E402
|
||
from django.core.asgi import get_asgi_application # noqa: E402
|
||
|
||
from server.ws.routing import websocket_urlpatterns # noqa: E402
|
||
|
||
application = ProtocolTypeRouter({
|
||
"http": get_asgi_application(),
|
||
"websocket": URLRouter(websocket_urlpatterns),
|
||
})
|