Django Channels HTTP support extend documentation
I am interested in using Channels to support both my HTTP async requests, as well as websockets.
There are millions tutorials out there on how to implement websocket, and that part is very clear to me.
Things change when it comes to implementing HTTP async requests using Channels.
The only example given in the documentation is to set http to django_asgi_app.
I can't find anywhere how to set urlpatterns to the http protocol mentioned, or how attach any routes to be handled through asgi http protocol.
I see that there is such thing as AsyncHttpConsumer however once again, I can't find a way to connect it to the url that I could connect with http protocol.
Would you mind adding an example to documentation of how to use async http with channels, not just websockets?
Thanks a million!
I am also looking for this and I've been struggling for two days now. Here's a Stackoverflow thread in case it yields any relevant results in future. https://stackoverflow.com/questions/76997708/django-setting-up-server-sent-events-with-channels-unhandled-exception-sseco
Hi @Tomislav-Zoricic. To enable "normal" http routes with channels, you only need to have this in asgi.py:
django_asgi_app = get_asgi_application()
application = ProtocolTypeRouter({
# All the normal urls defined in myproject/urls.py are now available
"http": django_asgi_app,
})
And then you need to have "daphne" as the first app in INSTALLED_APPS. Notice daphne takes over the runserver command so it looks like this:
Starting ASGI/Daphne version 4.0.0 development server at http://127.0.0.1:8000/
God speed! <3