Much of this code came from: https://fastapi.tiangolo.com/advanced/websockets/ Code for server: set PYTHONDONTWRITEBYTECODE=1 && uvicorn main:app --reload