From d735010ca4bc63599c2743a216e66761c3e46d3f Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 27 Feb 2024 22:01:58 -0800 Subject: [PATCH] Added boxscores API to Flask server --- src/__pycache__/boxscores.cpython-310.pyc | Bin 0 -> 919 bytes src/boxscores.py | 22 +++++++++ src/index.html | 55 ++++++++++++++++++++++ src/main.py | 14 ++++++ src/requirements.txt | 2 + 5 files changed, 93 insertions(+) create mode 100644 src/__pycache__/boxscores.cpython-310.pyc create mode 100644 src/boxscores.py create mode 100644 src/index.html create mode 100644 src/main.py create mode 100644 src/requirements.txt diff --git a/src/__pycache__/boxscores.cpython-310.pyc b/src/__pycache__/boxscores.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..75b1d7a865ef3a8bc791ac3dfa00a9e524af8381 GIT binary patch literal 919 zcmZ`%!EO^V5VgI#$tFrggea(@KafMSRnJvKX=y z1AnkN@*jMK4_r9$3!E6cgq8zddHmMnvERHIxv|kkFzRpLc_TpRhx@rb2>d*PsdvFJ z#Bh!ZJjU2zl9M7B2ObBoAC5!7A&aiiIAVNS5t6zXBSIguZ9CKWe|GGT-)X@0o} zj>vFYXaL=u)9IW~X~EA#$+*f~=z25&gfI_b>Nj8vs__affe<5Cs6t2R6K25{TH*?` z5LRNy+n^#W`iz%B71ZGhd4E`ib+kelnMU2b#;mdBeJi|-s;G`v$WcGdFub!KP6tO| z1XFK=nZl#5+x|HO;rN0mQsFP;9f4qCJ9IKp{8CVts|`j6hhN<`>F?UmrL3B8hc~~T zCg-x?Nj}f0PL5)x0!sJybD7ax4*;wql}p d{4KZG_`-Wi@qQuMJm&+axQ@YePzS?Deglvb^$h?3 literal 0 HcmV?d00001 diff --git a/src/boxscores.py b/src/boxscores.py new file mode 100644 index 0000000..99a96ad --- /dev/null +++ b/src/boxscores.py @@ -0,0 +1,22 @@ +from nba_api.stats.endpoints import boxscoretraditionalv2 +from nba_api.stats.static import teams +from nba_api.stats.endpoints import leaguegamefinder + +def boxscores_For_Latest_Game(): + + nba_teams = teams.get_teams() + # Select the dictionary for the Celtics, which contains their team ID + kings = [team for team in nba_teams if team['abbreviation'] == 'SAC'][0] + kings_id = kings['id'] + + + # Query for games where the Celtics were playing + gamefinder = leaguegamefinder.LeagueGameFinder(team_id_nullable=kings_id) + # The first DataFrame of those returned is what we want. + games = gamefinder.get_data_frames()[0] + games.head() + + + boxScore = boxscoretraditionalv2.BoxScoreTraditionalV2(games.head()["GAME_ID"][0]) + + return(boxScore.get_dict()) diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..5ce2876 --- /dev/null +++ b/src/index.html @@ -0,0 +1,55 @@ + + + + + + BANG + + + + + +

TABLE

+ + + + + + + + + + + + +
PlayerFGMFGA
+ + + \ No newline at end of file diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..3740e07 --- /dev/null +++ b/src/main.py @@ -0,0 +1,14 @@ +import boxscores +from flask import Flask, jsonify +from flask_cors import CORS + +app = Flask(__name__) +CORS(app) + +@app.route("/boxscore") +def names(): + return jsonify(boxscores.boxscores_For_Latest_Game()) + +if __name__ == "__main__": + app.run(debug=True) + diff --git a/src/requirements.txt b/src/requirements.txt new file mode 100644 index 0000000..0c3d82e --- /dev/null +++ b/src/requirements.txt @@ -0,0 +1,2 @@ +nba_api +flask \ No newline at end of file