From d1ac7586f792bbc29a6b115c95dad0555287d77d Mon Sep 17 00:00:00 2001 From: Nadege Date: Mon, 9 Dec 2019 18:27:25 +0100 Subject: [PATCH] SSE --- posts/routing.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 posts/routing.py diff --git a/posts/routing.py b/posts/routing.py new file mode 100644 index 0000000..cfe30ff --- /dev/null +++ b/posts/routing.py @@ -0,0 +1,16 @@ +import django_eventstream +from channels.auth import AuthMiddlewareStack +from channels.http import AsgiHandler +from channels.routing import URLRouter, ProtocolTypeRouter +from django.urls import re_path + +urlpatterns = [ + re_path(r'^events/', + AuthMiddlewareStack(URLRouter(django_eventstream.routing.urlpatterns)), + {'channels':['notice']}), + re_path(r'',AsgiHandler) +] + +application = ProtocolTypeRouter({ + 'http': URLRouter(urlpatterns) +}) \ No newline at end of file