Skip to content

Commit

Permalink
Adjusted deployment asgi.py example. (#1565)
Browse files Browse the repository at this point in the history
Co-authored-by: Carlton Gibson <carlton@noumenal.es>
  • Loading branch information
KStenK and carltongibson committed Nov 5, 2020
1 parent 8230e95 commit a32b513
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions docs/deploying.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@ Here's an example of what that ``asgi.py`` might look like:
import os
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from django.conf.urls import url
from django.core.asgi import get_asgi_application
from chat.consumers import AdminChatConsumer, PublicChatConsumer
# Fetch Django ASGI application early to ensure AppRegistry is populated
# before importing consumers and AuthMiddlewareStack that may import ORM
# models.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
django_asgi_app = get_asgi_application()
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from chat.consumers import AdminChatConsumer, PublicChatConsumer
application = ProtocolTypeRouter({
# Django's ASGI application to handle traditional HTTP requests
"http": get_asgi_application(),
"http": django_asgi_app,
# WebSocket chat handler
"websocket": AuthMiddlewareStack(
Expand All @@ -44,7 +49,6 @@ Here's an example of what that ``asgi.py`` might look like:
),
})
Setting up a channel backend
----------------------------

Expand Down

0 comments on commit a32b513

Please sign in to comment.