test7
This commit is contained in:
16
get_data.py
16
get_data.py
@@ -3472,7 +3472,7 @@ def get_image(points, bib, count_point):
|
||||
draw.text((text_x, text_y), label, font=font, fill=(255, 255, 255, 255))
|
||||
|
||||
# --- сохраняем картинку в оперативную память ---
|
||||
filename = f"shots_{bib}_{count_point}.png"
|
||||
filename = f"{bib}_shots_{count_point}"
|
||||
|
||||
buf = BytesIO()
|
||||
try:
|
||||
@@ -3487,7 +3487,7 @@ def get_image(points, bib, count_point):
|
||||
|
||||
# формируем URL для vMix
|
||||
public_base = f"https://{MYHOST}.tvstart.ru"
|
||||
public_url = f"{public_base.rstrip('/')}/shotmaps/{filename}"
|
||||
public_url = f"{public_base.rstrip('/')}/image/{filename}"
|
||||
|
||||
# logger.info(
|
||||
# f"[shotmap] generated in-memory shotmap for bib={bib}, ver={count_point} "
|
||||
@@ -3495,6 +3495,18 @@ def get_image(points, bib, count_point):
|
||||
# )
|
||||
return public_url
|
||||
|
||||
@app.get("/image/{player_id_shots}")
|
||||
async def get_shotmap_image(player_id_shots: str):
|
||||
"""
|
||||
Отдаёт картинку карты бросков из оперативной памяти.
|
||||
player_id_shots должен совпадать с ключом в SHOTMAP_CACHE, например "23_shots".
|
||||
"""
|
||||
data = SHOTMAP_CACHE.get(player_id_shots)
|
||||
if not data:
|
||||
raise HTTPException(status_code=404, detail="Shotmap not found in memory")
|
||||
|
||||
return Response(content=data, media_type="image/png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(
|
||||
|
||||
Reference in New Issue
Block a user