| 1 |
import asyncio |
| 2 |
import time |
| 3 |
from typing import AsyncGenerator |
| 4 |
|
| 5 |
from litestar import Litestar, websocket_stream |
| 6 |
|
| 7 |
|
| 8 |
@websocket_stream("/") |
| 9 |
async def ping() -> AsyncGenerator[float, None]: |
| 10 |
while True: |
| 11 |
yield time.time() |
| 12 |
await asyncio.sleep(0.5) |
| 13 |
|
| 14 |
|
| 15 |
app = Litestar([ping]) |