Category: fastapi

Problem

Broadcast message to all clients.

Solution

  for connection in active:
    await connection.send_json(message)
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path