good luck
This commit is contained in:
@@ -1,32 +1,51 @@
|
||||
from app import app
|
||||
from flask import render_template, jsonify
|
||||
from app.scoreboard.process_data import extract_game_info
|
||||
import json
|
||||
|
||||
SCOREBOARD_DATA_FILE = 'app/data/scoreboard_data.json'
|
||||
from flask import render_template, jsonify
|
||||
|
||||
@app.route('/')
|
||||
from app import app
|
||||
from app.config import SCOREBOARD_DATA_FILE
|
||||
from app.scoreboard.process_data import extract_game_info
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/scoreboard')
|
||||
return render_template("index.html")
|
||||
|
||||
|
||||
@app.route("/scoreboard")
|
||||
def get_scoreboard():
|
||||
try:
|
||||
with open(SCOREBOARD_DATA_FILE, 'r') as json_file:
|
||||
with open(SCOREBOARD_DATA_FILE, "r") as json_file:
|
||||
scoreboard_data = json.load(json_file)
|
||||
except FileNotFoundError:
|
||||
return jsonify({"error": "Failed to retrieve scoreboard data. File not found."})
|
||||
except json.JSONDecodeError:
|
||||
return jsonify({"error": "Failed to retrieve scoreboard data. Invalid JSON format."})
|
||||
return jsonify(
|
||||
{"error": "Failed to retrieve scoreboard data. Invalid JSON format."}
|
||||
)
|
||||
|
||||
if scoreboard_data:
|
||||
live_games = [game for game in extract_game_info(scoreboard_data) if game["Game State"] == "LIVE"]
|
||||
pre_games = [game for game in extract_game_info(scoreboard_data) if game["Game State"] == "PRE"]
|
||||
final_games = [game for game in extract_game_info(scoreboard_data) if game["Game State"] == "FINAL"]
|
||||
return jsonify({
|
||||
"live_games": live_games,
|
||||
"pre_games": pre_games,
|
||||
"final_games": final_games
|
||||
})
|
||||
live_games = [
|
||||
game
|
||||
for game in extract_game_info(scoreboard_data)
|
||||
if game["Game State"] == "LIVE"
|
||||
]
|
||||
pre_games = [
|
||||
game
|
||||
for game in extract_game_info(scoreboard_data)
|
||||
if game["Game State"] == "PRE"
|
||||
]
|
||||
final_games = [
|
||||
game
|
||||
for game in extract_game_info(scoreboard_data)
|
||||
if game["Game State"] == "FINAL"
|
||||
]
|
||||
return jsonify(
|
||||
{
|
||||
"live_games": live_games,
|
||||
"pre_games": pre_games,
|
||||
"final_games": final_games,
|
||||
}
|
||||
)
|
||||
else:
|
||||
return jsonify({"error": "Failed to retrieve scoreboard data"})
|
||||
|
||||
Reference in New Issue
Block a user