mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-28 20:44:04 +03:00
Fixed linter check for #2506
This commit is contained in:
parent
c4eaf68982
commit
910ed86d11
|
@ -11,6 +11,7 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
from .websocket import websocket_application
|
from .websocket import websocket_application
|
||||||
|
|
||||||
# This allows easy placement of apps within the interior
|
# This allows easy placement of apps within the interior
|
||||||
|
@ -33,9 +34,9 @@ django_application = get_asgi_application()
|
||||||
|
|
||||||
|
|
||||||
async def application(scope, receive, send):
|
async def application(scope, receive, send):
|
||||||
if scope['type'] == 'http':
|
if scope["type"] == "http":
|
||||||
await django_application(scope, receive, send)
|
await django_application(scope, receive, send)
|
||||||
elif scope['type'] == 'websocket':
|
elif scope["type"] == "websocket":
|
||||||
await websocket_application(scope, receive, send)
|
await websocket_application(scope, receive, send)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f"Unknown scope type {scope['type']}")
|
raise NotImplementedError(f"Unknown scope type {scope['type']}")
|
||||||
|
|
|
@ -2,17 +2,12 @@ async def websocket_application(scope, receive, send):
|
||||||
while True:
|
while True:
|
||||||
event = await receive()
|
event = await receive()
|
||||||
|
|
||||||
if event['type'] == 'websocket.connect':
|
if event["type"] == "websocket.connect":
|
||||||
await send({
|
await send({"type": "websocket.accept"})
|
||||||
'type': 'websocket.accept'
|
|
||||||
})
|
|
||||||
|
|
||||||
if event['type'] == 'websocket.disconnect':
|
if event["type"] == "websocket.disconnect":
|
||||||
break
|
break
|
||||||
|
|
||||||
if event['type'] == 'websocket.receive':
|
if event["type"] == "websocket.receive":
|
||||||
if event['text'] == 'ping':
|
if event["text"] == "ping":
|
||||||
await send({
|
await send({"type": "websocket.send", "text": "pong!"})
|
||||||
'type': 'websocket.send',
|
|
||||||
'text': 'pong!'
|
|
||||||
})
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user