скрыл docs и тп
This commit is contained in:
51
get_data.py
51
get_data.py
@@ -121,7 +121,7 @@ def _fetch_game_once(tournament_id: int, game_id: int) -> dict:
|
||||
# если это не JSON — вернём текст
|
||||
data = {"raw": r.text}
|
||||
|
||||
return {"url": url, "json": data}
|
||||
return data
|
||||
|
||||
|
||||
def _game_poll_worker():
|
||||
@@ -166,7 +166,12 @@ async def lifespan(app: FastAPI):
|
||||
_worker_thread.join(timeout=2)
|
||||
print("🛑 Background thread stopped")
|
||||
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
app = FastAPI(
|
||||
lifespan=lifespan,
|
||||
docs_url=None, # ❌ отключает /docs
|
||||
redoc_url=None, # ❌ отключает /redoc
|
||||
openapi_url=None # ❌ отключает /openapi.json
|
||||
)
|
||||
|
||||
|
||||
@app.get("/games")
|
||||
@@ -179,8 +184,8 @@ async def games():
|
||||
return Response(content=json_schedule, media_type="application/json")
|
||||
|
||||
|
||||
@app.get("/games/html")
|
||||
async def games_html():
|
||||
@app.get("/select")
|
||||
async def select():
|
||||
df = load_today_schedule()
|
||||
if df.empty:
|
||||
return HTMLResponse(
|
||||
@@ -315,7 +320,7 @@ async def game_url():
|
||||
"tournament_id": current_tournament_id
|
||||
})
|
||||
|
||||
@app.get("/game/data")
|
||||
@app.get("/data")
|
||||
async def game_data():
|
||||
with _latest_lock:
|
||||
if latest_game_data:
|
||||
@@ -324,6 +329,42 @@ async def game_data():
|
||||
return JSONResponse({"error": latest_game_error}, status_code=502)
|
||||
return JSONResponse({"message": "Ещё нет данных. Выберите матч и подождите первое обновление."})
|
||||
|
||||
|
||||
@app.get("/referee")
|
||||
async def referee():
|
||||
json_data = latest_game_data["data"]
|
||||
referees_id = [
|
||||
json_data["game"]["mref1_id"],
|
||||
json_data["game"]["mref2_id"],
|
||||
json_data["game"]["lref1_id"],
|
||||
json_data["game"]["lref2_id"],
|
||||
]
|
||||
data_referees = [
|
||||
{
|
||||
"number": json_data["game"]["mref1_num"],
|
||||
"fullname": f'{json_data["game"]["mref1"].split()[1]} {json_data["game"]["mref1"].split()[0]}',
|
||||
},
|
||||
{
|
||||
"number": json_data["game"]["mref2_num"],
|
||||
"fullname": f'{json_data["game"]["mref2"].split()[1]} {json_data["game"]["mref2"].split()[0]}',
|
||||
},
|
||||
{
|
||||
"number": json_data["game"]["lref1_num"],
|
||||
"fullname": f'{json_data["game"]["lref1"].split()[1]} {json_data["game"]["lref1"].split()[0]}',
|
||||
},
|
||||
{
|
||||
"number": json_data["game"]["lref2_num"],
|
||||
"fullname": f'{json_data["game"]["lref2"].split()[1]} {json_data["game"]["lref2"].split()[0]}',
|
||||
},
|
||||
]
|
||||
return data_referees
|
||||
|
||||
|
||||
|
||||
# def team(who:str):
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(
|
||||
"get_data:app", host="0.0.0.0", port=8000, reload=True, log_level="debug"
|
||||
|
||||
Reference in New Issue
Block a user