dedlepexa commited on
Commit
e2cc46b
·
verified ·
1 Parent(s): e54e4ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -8
app.py CHANGED
@@ -179,6 +179,7 @@ async def video(path: str):
179
  import requests
180
  from fastapi import Request
181
 
 
182
  DATA_URL = "https://script.google.com/macros/s/AKfycbxPYAG3xM-ju3V8DockaI2UbOIpUd4w5XO2FZsdOagsUzfNKjX_wph1DA-sqeUPhVmJ/exec"
183
 
184
 
@@ -225,7 +226,13 @@ def format_user(user, info):
225
  @app.get("/players")
226
  async def players(request: Request):
227
 
228
- query = request.query_params.get("get")
 
 
 
 
 
 
229
 
230
  if not query:
231
  return PlainTextResponse("use ?get=all or ?get=nickname")
@@ -272,15 +279,23 @@ async def players(request: Request):
272
 
273
  # 📦 ALL
274
  if query == "all":
275
- result = []
 
 
 
 
 
 
 
 
 
 
 
276
 
277
- for user, info in data.items():
278
- if is_item:
279
- result.append(format_item(user, info))
280
- else:
281
- result.append(format_user(user, info))
282
 
283
- return PlainTextResponse("%newline%".join(result))
284
 
285
  # 🔍 ONE USER
286
  if query not in data:
 
179
  import requests
180
  from fastapi import Request
181
 
182
+ PAGE_SIZE = 50
183
  DATA_URL = "https://script.google.com/macros/s/AKfycbxPYAG3xM-ju3V8DockaI2UbOIpUd4w5XO2FZsdOagsUzfNKjX_wph1DA-sqeUPhVmJ/exec"
184
 
185
 
 
226
  @app.get("/players")
227
  async def players(request: Request):
228
 
229
+ query = request.query_params.get("get")
230
+ start_raw = request.query_params.get("start")
231
+
232
+ start = 0
233
+ if start_raw and start_raw.isdigit():
234
+ start = int(start_raw)
235
+
236
 
237
  if not query:
238
  return PlainTextResponse("use ?get=all or ?get=nickname")
 
279
 
280
  # 📦 ALL
281
  if query == "all":
282
+ result = []
283
+
284
+ items = list(data.items())
285
+
286
+ # 🔥 NEW: pagination
287
+ chunk = items[start:start + PAGE_SIZE]
288
+
289
+ for user, info in chunk:
290
+ if is_item:
291
+ result.append(format_item(user, info))
292
+ else:
293
+ result.append(format_user(user, info))
294
 
295
+ if not chunk:
296
+ return PlainTextResponse("end")
 
 
 
297
 
298
+ return PlainTextResponse("%newline%".join(result))
299
 
300
  # 🔍 ONE USER
301
  if query not in data: