1*1625Smax.romanov@nginx.comasync def application(scope, receive, send): 2*1625Smax.romanov@nginx.com if scope['type'] == 'websocket': 3*1625Smax.romanov@nginx.com while True: 4*1625Smax.romanov@nginx.com m = await receive() 5*1625Smax.romanov@nginx.com if m['type'] == 'websocket.connect': 6*1625Smax.romanov@nginx.com await send({ 7*1625Smax.romanov@nginx.com 'type': 'websocket.accept', 8*1625Smax.romanov@nginx.com }) 9*1625Smax.romanov@nginx.com 10*1625Smax.romanov@nginx.com if m['type'] == 'websocket.receive': 11*1625Smax.romanov@nginx.com await send({ 12*1625Smax.romanov@nginx.com 'type': 'websocket.send', 13*1625Smax.romanov@nginx.com 'bytes': m.get('bytes', None), 14*1625Smax.romanov@nginx.com 'text': m.get('text', None), 15*1625Smax.romanov@nginx.com }) 16*1625Smax.romanov@nginx.com 17*1625Smax.romanov@nginx.com if m['type'] == 'websocket.disconnect': 18*1625Smax.romanov@nginx.com break; 19