Update 2025-05-21_08:58:06

This commit is contained in:
oib
2025-05-21 08:58:07 +02:00
parent 1011f58d00
commit 39934115a1
28 changed files with 2166 additions and 672 deletions

27
streams.py Normal file
View File

@ -0,0 +1,27 @@
# streams.py — Public streams endpoint for dicta2stream
from fastapi import APIRouter
from fastapi import APIRouter
from pathlib import Path
import json
router = APIRouter()
@router.get("/streams")
def list_streams():
txt_path = Path("./public_streams.txt")
if not txt_path.exists():
return {"streams": []}
try:
streams = []
with txt_path.open("r") as f:
for line in f:
line = line.strip()
if not line:
continue
try:
streams.append(json.loads(line))
except Exception:
continue # skip malformed lines
return {"streams": streams}
except Exception:
return {"streams": []}