Skip to content

WebSockets for Continuous Data Transmission #38

Open
@Wytamma

Description

Replace polling with web sockets e.g.

from fastapi import FastAPI, WebSocket

app = FastAPI()

@app.websocket("/data")
async def data_websocket(websocket: WebSocket):
    await websocket.accept()
    while True:
        data = await generate_data()  # Your function to get real-time data
        await websocket.send_json(data)
        await asyncio.sleep(1)  # Adjust based on desired update frequency

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions