From: Roland Häder Date: Tue, 20 Jun 2023 19:59:46 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e81256ae0ecf73006ad384c90ef487bb1616843d;p=fba.git Continued: - okay /api/top.json while the view is called /scoreboard, renamed it --- diff --git a/api.py b/api.py index 41e0589..eb7a8f8 100644 --- a/api.py +++ b/api.py @@ -51,8 +51,8 @@ def api_info(): "slogan" : config.get("slogan") } -@router.get(config.get("base_url") + "/api/top.json", response_class=JSONResponse) -def api_top(mode: str, amount: int): +@router.get(config.get("base_url") + "/api/scoreboard.json", response_class=JSONResponse) +def api_scoreboard(mode: str, amount: int): if amount > 500: raise HTTPException(status_code=400, detail="Too many results") @@ -163,19 +163,19 @@ def scoreboard(request: Request, mode: str, amount: int): response = None if mode == "blocker" and amount > 0: - response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=blocker&amount={amount}") + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=blocker&amount={amount}") elif mode == "blocked" and amount > 0: - response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=blocked&amount={amount}") + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=blocked&amount={amount}") elif mode == "reference" and amount > 0: - response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=reference&amount={amount}") + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=reference&amount={amount}") elif mode == "software" and amount > 0: - response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=software&amount={amount}") + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=software&amount={amount}") elif mode == "command" and amount > 0: - response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=command&amount={amount}") + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=command&amount={amount}") elif mode == "error_code" and amount > 0: - response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=error_code&amount={amount}") + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=error_code&amount={amount}") elif mode == "avg_peers" and amount > 0: - response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/top.json?mode=avg_peers&amount={amount}") + response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/scoreboard.json?mode=avg_peers&amount={amount}") else: raise HTTPException(status_code=400, detail="No filter specified")