Compare commits
2 Commits
339ef339e4
...
2ffa623877
Author | SHA1 | Date |
---|---|---|
Anorak_1 | 2ffa623877 | |
Anorak_1 | 8233183210 |
20
backend.py
20
backend.py
|
@ -38,6 +38,25 @@ class LeaderGetAPI(Resource):
|
||||||
# dictionary of leaderboard is json, encoding using json.dumps results in double encoding with "" and return to browser as type string
|
# dictionary of leaderboard is json, encoding using json.dumps results in double encoding with "" and return to browser as type string
|
||||||
return list(leaderboard)
|
return list(leaderboard)
|
||||||
|
|
||||||
|
class LeaderGetCacheAPI(Resource):
|
||||||
|
|
||||||
|
def post(self):
|
||||||
|
data = request.get_json()
|
||||||
|
# Pylance error seems to be fine, no problems I guess
|
||||||
|
gamemap = data['map']
|
||||||
|
dbcon = sqlite3.connect("leaderboard.db")
|
||||||
|
db = dbcon.cursor()
|
||||||
|
leaderboard = db.execute(f"SELECT time_username,time_time FROM leaderboard WHERE time_map = '{gamemap}' ORDER BY time_time LIMIT 10").fetchall()
|
||||||
|
db.close()
|
||||||
|
dbcon.close()
|
||||||
|
# dictionary of leaderboard is json, encoding using json.dumps results in double encoding with "" and return to browser as type string
|
||||||
|
#leaderwmap = gamemap + list(leaderboard)
|
||||||
|
#print(leaderwmap)
|
||||||
|
leaderwmap = {
|
||||||
|
"map": gamemap,
|
||||||
|
"leaderboard": list(leaderboard)
|
||||||
|
}
|
||||||
|
return leaderwmap
|
||||||
class TokenAPI(Resource):
|
class TokenAPI(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
print(request.remote_addr)
|
print(request.remote_addr)
|
||||||
|
@ -45,6 +64,7 @@ class TokenAPI(Resource):
|
||||||
api.add_resource(LeaderGetAPI, "/get/")
|
api.add_resource(LeaderGetAPI, "/get/")
|
||||||
api.add_resource(LeaderPostAPI, "/post/")
|
api.add_resource(LeaderPostAPI, "/post/")
|
||||||
api.add_resource(TokenAPI, "/token/")
|
api.add_resource(TokenAPI, "/token/")
|
||||||
|
api.add_resource(LeaderGetCacheAPI, "/cache/")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0", port=25540)
|
app.run(host="0.0.0.0", port=25540)
|
Loading…
Reference in New Issue