Paweł Łaba commited on
Commit
423991c
·
1 Parent(s): 1b4ebab
Files changed (1) hide show
  1. app.py +9 -38
app.py CHANGED
@@ -67,6 +67,15 @@ async def read_root():
67
  return HTMLResponse(content="Plik index.html nie został znaleziony", status_code=404)
68
 
69
 
 
 
 
 
 
 
 
 
 
70
 
71
  @app.post("/move")
72
  async def get_move(request: Request):
@@ -90,42 +99,4 @@ async def get_move(request: Request):
90
  except Exception as e:
91
  raise HTTPException(status_code=500, detail=str(e))
92
 
93
- @app.post("/game")
94
- async def add_game(data: dict):
95
- """
96
- Endpoint do dodania gry do pliku
97
- """
98
- try:
99
- board = data.get("board")
100
- win = data.get("win")
101
-
102
- if not board or win is None:
103
- raise HTTPException(status_code=400, detail="Brak planszy lub informacji o wygranej w żądaniu")
104
-
105
- if len(board) != 9 or not all(x in [0, 1, -1] for x in board):
106
- raise HTTPException(status_code=400, detail="Nieprawidłowe dane planszy")
107
-
108
- if os.path.exists("gry.json"):
109
- with open("gry.json", "r") as file:
110
- games_data = json.load(file)
111
- else:
112
- games_data = []
113
-
114
- games_data.append({"board": board, "win": win})
115
-
116
- with open("gry.json", "w") as file:
117
- json.dump(games_data, file)
118
-
119
- return {"status": "success"}
120
- except Exception as e:
121
- raise HTTPException(status_code=500, detail=str(e))
122
-
123
 
124
- @app.get("/status")
125
- async def get_status():
126
- """Sprawdza status modelu"""
127
- return {
128
- "status": "success",
129
- "model_loaded": ai.model is not None,
130
- "model_path": ai.model_path,
131
- }
 
67
  return HTMLResponse(content="Plik index.html nie został znaleziony", status_code=404)
68
 
69
 
70
+ @app.get("/status")
71
+ async def get_status():
72
+ """Sprawdza status modelu"""
73
+ return {
74
+ "status": "success",
75
+ "model_loaded": ai.model is not None,
76
+ "model_path": ai.model_path,
77
+ }
78
+
79
 
80
  @app.post("/move")
81
  async def get_move(request: Request):
 
99
  except Exception as e:
100
  raise HTTPException(status_code=500, detail=str(e))
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102