django websocket

1、dwebsocket 

2、等框架都是错误的

3、  django/channels 才是正确姿势 555    

4、 

pip install -U channels

完成后,您应该添加channels到您的 INSTALLED_APPS设置:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    ...
    'channels',
)

然后,在以下位置进行默认路由myproject/routing.py

from channels.routing import ProtocolTypeRouter

application = ProtocolTypeRouter({
    # Empty for now (http->django views is added by default)
})

最后,将您的ASGI_APPLICATION设置设置为指向该路由对象作为根应用程序:

ASGI_APPLICATION = "myproject.routing.application"
posted @ 2019-03-09 01:05  MvloveYouForever  阅读(193)  评论(0编辑  收藏  举报