Ramesh-vani commited on
Commit
15fa6b0
·
verified ·
1 Parent(s): 58b3a52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -341,14 +341,14 @@ async def handle_user_input(websocket, process):
341
  await asyncio.sleep(0.1)
342
  if process.returncode is not None:
343
  break
344
- message = await websocket.recv()
345
- user_input = json.loads(message)
346
- print(user_input)
347
- print(f'Received user input: {user_input["command"]["command"]}')
348
- if not is_valid_input(user_input):
349
- await websocket.send("Invalid input. Please try again.")
350
- continue
351
- process_input(user_input, process)
352
  except websockets.ConnectionClosed:
353
  print("WebSocket connection closed")
354
  break
 
341
  await asyncio.sleep(0.1)
342
  if process.returncode is not None:
343
  break
344
+ # message = await websocket.recv()
345
+ async for message in websocket:
346
+ user_input = json.loads(message)
347
+ print(user_input)
348
+ print(f'Received user input: {user_input["command"]["command"]}')
349
+
350
+ process_input(user_input, process)
351
+ break
352
  except websockets.ConnectionClosed:
353
  print("WebSocket connection closed")
354
  break