Last active
April 24, 2018 19:56
-
-
Save DustinAlandzes/122413c67197e8a3c251f1528eb8f69b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from channels.generic import websockets | |
class ExampleConsumer(websockets.JsonWebsocketConsumer): | |
def receive(self, content): | |
print(content) # {"test": "data"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from channels.routing import route_class | |
from consumers import ExampleConsumer | |
channel_routing = [ | |
route_class(ExampleConsumer) | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ws = new WebSocket("ws://localhost:8000/") | |
var msg = JSON.stringify({"test": "data"}) | |
ws.send(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment