mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2025-06-28 16:25:44 +08:00
Improved websocket consumer
This commit is contained in:
parent
63d16eae17
commit
8d5a316d54
2 changed files with 34 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
|
||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||
from channels.security.websocket import AllowedHostsOriginValidator
|
||||
from channels.auth import AuthMiddlewareStack
|
||||
from django.core.asgi import get_asgi_application
|
||||
import api.routing
|
||||
|
@ -13,9 +14,11 @@ django_asgi_app = get_asgi_application()
|
|||
|
||||
application = ProtocolTypeRouter({
|
||||
"http": django_asgi_app,
|
||||
'websocket': AuthMiddlewareStack(
|
||||
URLRouter(
|
||||
[re_path(r'ws/', URLRouter(api.routing.websocket_urlpatterns))]
|
||||
)
|
||||
),
|
||||
'websocket': AllowedHostsOriginValidator(
|
||||
AuthMiddlewareStack(
|
||||
URLRouter(
|
||||
[re_path(r'ws/', URLRouter(api.routing.websocket_urlpatterns))]
|
||||
)
|
||||
),
|
||||
)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue