Skip to content

Instantly share code, notes, and snippets.

@NicolaiSoeborg
Created March 11, 2025 16:02
Show Gist options
  • Save NicolaiSoeborg/ac580eb9cba301d714aeece9a9501b73 to your computer and use it in GitHub Desktop.
Save NicolaiSoeborg/ac580eb9cba301d714aeece9a9501b73 to your computer and use it in GitHub Desktop.
CTFd convert for having a live scoreboard on CTFTime.org
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