-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (27 loc) · 823 Bytes
/
app.py
File metadata and controls
33 lines (27 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Flask, jsonify
from kahoot import get_kahoot_leaderboard, get_attendance as load_attendance
import os
app = Flask(__name__)
attendance = load_attendance()
scores = get_kahoot_leaderboard()
@app.route("/attendance")
def get_attendance_endpoint():
return jsonify({
"success": True,
"data": {"attendance": attendance},
})
@app.route("/leaderboard")
def get_leaderboard():
return jsonify({
"success": True,
"data": {"kahoot_scores": scores},
})
@app.route("/leaderboard/<int:week_id>")
def get_weekly_leaderboard(week_id):
return jsonify({
"success": True,
"data": {"kahoot_scores": get_kahoot_leaderboard(week_id)},
})
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=port)