gemini-boggle/rank.cgi

34 lines
716 B
Plaintext
Raw Permalink Normal View History

2023-08-04 15:58:20 +00:00
#!/usr/bin/env python3
import random
from helpers import get_client_cert
from db import *
TLS_CLIENT_HASH = get_client_cert()
user_id = check_hash(TLS_CLIENT_HASH)
user_name = get_name(user_id) or "[Not Set]"
2023-08-04 21:34:52 +00:00
game_id = get_game_id(user_id)
if game_id:
print("=> game.cgi back to game")
2023-08-04 15:58:20 +00:00
print("=> lobby.cgi lobby")
print("=> login.cgi login")
2023-08-04 21:34:52 +00:00
print("=> new_game.cgi new game")
2023-08-04 15:58:20 +00:00
conn=create_connection()
with conn:
cur = conn.cursor()
2023-08-06 12:03:47 +00:00
cur.execute("SELECT name,score FROM users WHERE score>0 ORDER BY score DESC")
2023-08-04 15:58:20 +00:00
rows = cur.fetchall()
print("# Ranking")
print("```")
rank=1
print(f"rank score name")
for row in rows:
print(f"{rank:4d} {row[1]:5d} {row[0]:32s}")
rank+=1
print("```")