mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-07 23:51:36 +01:00
dirty hack because lazy
This commit is contained in:
13
server.py
13
server.py
@@ -3,6 +3,7 @@ import flask
|
|||||||
import requests
|
import requests
|
||||||
import argparse
|
import argparse
|
||||||
import flask_caching as fcache
|
import flask_caching as fcache
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
app = flask.Flask("open-leaderboard")
|
app = flask.Flask("open-leaderboard")
|
||||||
@@ -16,7 +17,7 @@ PARAM_END = "end"
|
|||||||
|
|
||||||
BASE_URL = "http://{server}{path}?{paramStart}={start}&{paramEnd}={end}"
|
BASE_URL = "http://{server}{path}?{paramStart}={start}&{paramEnd}={end}"
|
||||||
MAX_ENTRY = "http://{server}/getmaxentries"
|
MAX_ENTRY = "http://{server}/getmaxentries"
|
||||||
FIND_PLAYER = "http://{server}/findplayer?string={pname}"
|
FIND_PLAYER = "http://{server}/getplayer?name={pname}"
|
||||||
SEGMENT = 100
|
SEGMENT = 100
|
||||||
SEPERATOR = ','
|
SEPERATOR = ','
|
||||||
|
|
||||||
@@ -95,14 +96,14 @@ def leaderboard():
|
|||||||
|
|
||||||
if playerName:
|
if playerName:
|
||||||
playersWithRankUrl = FIND_PLAYER.format(server=SERVER, pname=playerName)
|
playersWithRankUrl = FIND_PLAYER.format(server=SERVER, pname=playerName)
|
||||||
playersWithRank = str(requests.get(playersWithRankUrl).content, "utf-8").split("|")
|
playersWithRank = str(requests.get(playersWithRankUrl).content, "utf-8")
|
||||||
|
print(playersWithRank)
|
||||||
if len(playersWithRank) == 1 and playersWithRank[0] == "":
|
if playersWithRank == "[]":
|
||||||
cannotFindPlayer = flask.Markup("<div class=noPlayerFound>No player of that name</div>")
|
cannotFindPlayer = flask.Markup("<div class=noPlayerFound>No player of that name</div>")
|
||||||
start = 0
|
start = 0
|
||||||
else:
|
else:
|
||||||
searchName, playerID, rating, games, win, rank = playersWithRank[0].split(SEPERATOR)
|
searchName = playersWithRank.split(",")[1].strip(" '")
|
||||||
rank = int(rank)
|
rank = int(playersWithRank.split(",")[4].strip(" ')"))
|
||||||
start = rank - (rank % SEGMENT)
|
start = rank - (rank % SEGMENT)
|
||||||
|
|
||||||
end = start + SEGMENT
|
end = start + SEGMENT
|
||||||
|
|||||||
Reference in New Issue
Block a user