Created
March 11, 2025 16:02
-
-
Save NicolaiSoeborg/ac580eb9cba301d714aeece9a9501b73 to your computer and use it in GitHub Desktop.
CTFd convert for having a live scoreboard on CTFTime.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httpx | |
from flask import Flask | |
app = Flask(__name__) | |
def ctfd_to_ctftime(data): | |
for row in data: | |
if row['account_type'] == 'team': | |
yield {'pos': row['pos'], 'team': row['name'], 'score': row['score']} | |
@app.route("/") | |
def hello_world(): | |
r = httpx.get("https://kalmarc.tf/api/v1/scoreboard").json() | |
if r['success']: | |
return {'standings': list(ctfd_to_ctftime(r['data']))} | |
return "<p>Hello, World!</p>" | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment