mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-11 04:07:48 +03:00
19 lines
527 B
Python
19 lines
527 B
Python
|
async def websocket_application(scope, receive, send):
|
||
|
while True:
|
||
|
event = await receive()
|
||
|
|
||
|
if event['type'] == 'websocket.connect':
|
||
|
await send({
|
||
|
'type': 'websocket.accept'
|
||
|
})
|
||
|
|
||
|
if event['type'] == 'websocket.disconnect':
|
||
|
break
|
||
|
|
||
|
if event['type'] == 'websocket.receive':
|
||
|
if event['text'] == 'ping':
|
||
|
await send({
|
||
|
'type': 'websocket.send',
|
||
|
'text': 'pong!'
|
||
|
})
|