Spaces:
Running
Running
James McCool commited on
Commit ·
1449e4e
1
Parent(s): ef7d9db
Adding dyanasty rankings support
Browse files
app.py
CHANGED
|
@@ -48,6 +48,8 @@ ranker_options = ['Guillotine', 'Dwain', 'Freedman', 'Ian', 'Waz', 'Kendall', 'S
|
|
| 48 |
ranker_replacements = ['guillotine', 'dwain', 'freedman', 'ian', 'waz', 'kendall', 'sam', 'laghezza', 'ronis', 'berry']
|
| 49 |
projections_options = ['Aggregate', 'Kickers', 'Defenses']
|
| 50 |
projections_replacements = ['aggregate', 'kickers', 'defenses']
|
|
|
|
|
|
|
| 51 |
preseason_options = ['Gene', 'Freedman']
|
| 52 |
preseason_replacements = ['gene', 'freedman']
|
| 53 |
data_update_options = ['Thor500', 'Rookie Super Model', 'Betting Model', 'DFS', 'DVP', 'Strength of Sched', 'Air Yards', 'FAAB']
|
|
@@ -483,7 +485,38 @@ with tab1:
|
|
| 483 |
st.cache_data.clear()
|
| 484 |
for key in st.session_state.keys():
|
| 485 |
del st.session_state[key]
|
| 486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
|
| 488 |
with tab2:
|
| 489 |
with st.container():
|
|
|
|
| 48 |
ranker_replacements = ['guillotine', 'dwain', 'freedman', 'ian', 'waz', 'kendall', 'sam', 'laghezza', 'ronis', 'berry']
|
| 49 |
projections_options = ['Aggregate', 'Kickers', 'Defenses']
|
| 50 |
projections_replacements = ['aggregate', 'kickers', 'defenses']
|
| 51 |
+
dynasty_options = ['Superflex', 'Rookie', 'Dynasty']
|
| 52 |
+
dynasty_replacements = ['superflex', 'rookie', 'dynasty']
|
| 53 |
preseason_options = ['Gene', 'Freedman']
|
| 54 |
preseason_replacements = ['gene', 'freedman']
|
| 55 |
data_update_options = ['Thor500', 'Rookie Super Model', 'Betting Model', 'DFS', 'DVP', 'Strength of Sched', 'Air Yards', 'FAAB']
|
|
|
|
| 485 |
st.cache_data.clear()
|
| 486 |
for key in st.session_state.keys():
|
| 487 |
del st.session_state[key]
|
| 488 |
+
|
| 489 |
+
with st.container():
|
| 490 |
+
st.header("Update Dynasty Rankings")
|
| 491 |
+
dynasty_col, blank_col1, blank_col2, blank_col3 = st.columns([3, 3, 3, 3])
|
| 492 |
+
|
| 493 |
+
with dynasty_col:
|
| 494 |
+
st.info("Update Dynasty Rankings")
|
| 495 |
+
choose_dynasty_ranker = st.selectbox("Choose Ranker", ranker_options, key='dynasty_ranker')
|
| 496 |
+
choose_dynasty_type = st.selectbox("Choose Type", dynasty_options, key='dynasty_type')
|
| 497 |
+
choose_dynasty_ranker = ranker_replacements[ranker_options.index(choose_dynasty_ranker)]
|
| 498 |
+
choose_dynasty_type = dynasty_replacements[dynasty_options.index(choose_dynasty_type)]
|
| 499 |
+
if st.button("Update Dynasty Rankings", key='dynasty_rankings'):
|
| 500 |
+
response = requests.post(f"https://api.fantasylife.com/api/dynasty-rankings/v1/{choose_dynasty_ranker}/{choose_dynasty_type}/update", headers=headers, timeout=60)
|
| 501 |
+
if response.status_code == 200:
|
| 502 |
+
st.write("Uploading!")
|
| 503 |
+
st.write(response.json())
|
| 504 |
+
st.cache_data.clear()
|
| 505 |
+
for key in st.session_state.keys():
|
| 506 |
+
del st.session_state[key]
|
| 507 |
+
else:
|
| 508 |
+
st.write("Error uploading dynasty rankings")
|
| 509 |
+
try:
|
| 510 |
+
if response.text.strip(): # Check if response has content
|
| 511 |
+
st.write(response.json())
|
| 512 |
+
else:
|
| 513 |
+
st.write(f"Empty response. Status code: {response.status_code}")
|
| 514 |
+
except ValueError:
|
| 515 |
+
st.write(f"Invalid JSON response. Status code: {response.status_code}")
|
| 516 |
+
st.write(f"Response text: {response.text}")
|
| 517 |
+
st.cache_data.clear()
|
| 518 |
+
for key in st.session_state.keys():
|
| 519 |
+
del st.session_state[key]
|
| 520 |
|
| 521 |
with tab2:
|
| 522 |
with st.container():
|