James McCool commited on
Commit
46f4212
·
1 Parent(s): 4881c5c

added better error handling

Browse files
Files changed (1) hide show
  1. app.py +150 -37
app.py CHANGED
@@ -166,7 +166,7 @@ with tab1:
166
  choose_seasonal_ranker = st.selectbox("Choose Ranker", name_options, key='seasonal_ranker')
167
  choose_seasonal_ranker = api_replace_options[name_options.index(choose_seasonal_ranker)]
168
  if st.button("Update Seasonal Rankings", key='seasonal_rankings'):
169
- response = requests.post(f"https://api.fantasylife.com/api/expert-rankings/v1/{choose_seasonal_ranker}/seasonal/update", headers=headers)
170
  if response.status_code == 200:
171
  st.write("Uploading!")
172
  st.write(response.json())
@@ -175,7 +175,14 @@ with tab1:
175
  del st.session_state[key]
176
  else:
177
  st.write("Error uploading seasonal rankings")
178
- st.write(response.json())
 
 
 
 
 
 
 
179
  st.cache_data.clear()
180
  for key in st.session_state.keys():
181
  del st.session_state[key]
@@ -185,7 +192,7 @@ with tab1:
185
  choose_ros_ranker = st.selectbox("Choose Ranker", name_options, key='rest_of_season_ranker')
186
  choose_ros_ranker = api_replace_options[name_options.index(choose_ros_ranker)]
187
  if st.button("Update Rest of Season Rankings", key='rest_of_season_rankings'):
188
- response = requests.post(f"https://api.fantasylife.com/api/expert-rankings/v1/{choose_ros_ranker}/restofseason/update", headers=headers)
189
  if response.status_code == 200:
190
  st.write("Uploading!")
191
  st.write(response.json())
@@ -194,7 +201,14 @@ with tab1:
194
  del st.session_state[key]
195
  else:
196
  st.write("Error uploading rest of season rankings")
197
- st.write(response.json())
 
 
 
 
 
 
 
198
  st.cache_data.clear()
199
  for key in st.session_state.keys():
200
  del st.session_state[key]
@@ -204,7 +218,7 @@ with tab1:
204
  choose_weekly_ranker = st.selectbox("Choose Ranker", name_options, key='weekly_ranker')
205
  choose_weekly_ranker = api_replace_options[name_options.index(choose_weekly_ranker)]
206
  if st.button("Update Weekly Rankings", key='weekly_rankings'):
207
- response = requests.post(f"https://api.fantasylife.com/api/expert-rankings/v1/{choose_weekly_ranker}/weekly/update", headers=headers)
208
  if response.status_code == 200:
209
  st.write("Uploading!")
210
  st.write(response.json())
@@ -213,7 +227,14 @@ with tab1:
213
  del st.session_state[key]
214
  else:
215
  st.write("Error uploading weekly rankings")
216
- st.write(response.json())
 
 
 
 
 
 
 
217
  st.cache_data.clear()
218
  for key in st.session_state.keys():
219
  del st.session_state[key]
@@ -227,7 +248,7 @@ with tab1:
227
  choose_seasonal_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='seasonal_guillotine_ranker')
228
  choose_seasonal_guillotine_ranker = api_replace_options[name_options.index(choose_seasonal_guillotine_ranker)]
229
  if st.button("Update Seasonal Guillotine Rankings", key='seasonal_guillotine_rankings'):
230
- response = requests.post(f"https://api.fantasylife.com/api/guillotine-rankings/v1/{choose_seasonal_guillotine_ranker}/seasonal/update", headers=headers)
231
  if response.status_code == 200:
232
  st.write("Uploading!")
233
  st.write(response.json())
@@ -236,7 +257,14 @@ with tab1:
236
  del st.session_state[key]
237
  else:
238
  st.write("Error uploading seasonal guillotine rankings")
239
- st.write(response.json())
 
 
 
 
 
 
 
240
  st.cache_data.clear()
241
  for key in st.session_state.keys():
242
  del st.session_state[key]
@@ -246,7 +274,7 @@ with tab1:
246
  choose_rest_of_season_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='rest_of_season_guillotine_ranker')
247
  choose_rest_of_season_guillotine_ranker = api_replace_options[name_options.index(choose_rest_of_season_guillotine_ranker)]
248
  if st.button("Update Rest of Season Guillotine Rankings", key='rest_of_season_guillotine_rankings'):
249
- response = requests.post(f"https://api.fantasylife.com/api/guillotine-rankings/v1/{choose_rest_of_season_guillotine_ranker}/restofseason/update", headers=headers)
250
  if response.status_code == 200:
251
  st.write("Uploading!")
252
  st.write(response.json())
@@ -255,7 +283,14 @@ with tab1:
255
  del st.session_state[key]
256
  else:
257
  st.write("Error uploading rest of season guillotine rankings")
258
- st.write(response.json())
 
 
 
 
 
 
 
259
  st.cache_data.clear()
260
  for key in st.session_state.keys():
261
  del st.session_state[key]
@@ -265,7 +300,7 @@ with tab1:
265
  choose_weekly_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='weekly_guillotine_ranker')
266
  choose_weekly_guillotine_ranker = api_replace_options[name_options.index(choose_weekly_guillotine_ranker)]
267
  if st.button("Update Weekly Guillotine Rankings", key='weekly_guillotine_rankings'):
268
- response = requests.post(f"https://api.fantasylife.com/api/guillotine-rankings/v1/{choose_weekly_guillotine_ranker}/weekly/update", headers=headers)
269
  if response.status_code == 200:
270
  st.write("Uploading!")
271
  st.write(response.json())
@@ -274,7 +309,14 @@ with tab1:
274
  del st.session_state[key]
275
  else:
276
  st.write("Error uploading weekly guillotine rankings")
277
- st.write(response.json())
 
 
 
 
 
 
 
278
  st.cache_data.clear()
279
  for key in st.session_state.keys():
280
  del st.session_state[key]
@@ -290,7 +332,7 @@ with tab2:
290
  choose_seasonal_type = st.selectbox("Choose Type", proj_source_options, key='seasonal_type')
291
  choose_seasonal_type = proj_replace_options[proj_source_options.index(choose_seasonal_type)]
292
  if st.button("Update Seasonal Projections", key='seasonal_projections'):
293
- response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_seasonal_type}/seasonal/update", headers=headers)
294
  if response.status_code == 200:
295
  st.write("Uploading!")
296
  st.write(response.json())
@@ -299,7 +341,14 @@ with tab2:
299
  del st.session_state[key]
300
  else:
301
  st.write("Error uploading seasonal aggregate projections")
302
- st.write(response.json())
 
 
 
 
 
 
 
303
  st.cache_data.clear()
304
  for key in st.session_state.keys():
305
  del st.session_state[key]
@@ -308,7 +357,7 @@ with tab2:
308
  choose_weekly_type = st.selectbox("Choose Type", proj_source_options, key='weekly_type')
309
  choose_weekly_type = proj_replace_options[proj_source_options.index(choose_weekly_type)]
310
  if st.button("Update Weekly Projections", key='weekly_projections'):
311
- response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_weekly_type}/weekly/update", headers=headers)
312
  if response.status_code == 200:
313
  st.write("Uploading!")
314
  st.write(response.json())
@@ -317,7 +366,14 @@ with tab2:
317
  del st.session_state[key]
318
  else:
319
  st.write("Error uploading weekly projections")
320
- st.write(response.json())
 
 
 
 
 
 
 
321
  st.cache_data.clear()
322
  for key in st.session_state.keys():
323
  del st.session_state[key]
@@ -327,7 +383,7 @@ with tab2:
327
  choose_ros_type = st.selectbox("Choose Type", ros_source_options, key='rest_of_season_type')
328
  choose_ros_type = ros_replace_options[ros_source_options.index(choose_ros_type)]
329
  if st.button("Update Rest of Season Projections", key='rest_of_season_projections'):
330
- response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_ros_type}/restofseason/update", headers=headers)
331
  if response.status_code == 200:
332
  st.write("Uploading!")
333
  st.write(response.json())
@@ -336,7 +392,14 @@ with tab2:
336
  del st.session_state[key]
337
  else:
338
  st.write("Error uploading rest of season projections")
339
- st.write(response.json())
 
 
 
 
 
 
 
340
  st.cache_data.clear()
341
  for key in st.session_state.keys():
342
  del st.session_state[key]
@@ -350,7 +413,7 @@ with tab2:
350
  choose_guillotine_seasonal_type = st.selectbox("Choose Type", proj_source_options, key='seasonal_guillotine_type')
351
  choose_guillotine_seasonal_type = proj_replace_options[proj_source_options.index(choose_guillotine_seasonal_type)]
352
  if st.button("Update Seasonal Guillotine Projections", key='seasonal_guillotine_projections'):
353
- response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_guillotine_seasonal_type}/seasonal/update", headers=headers)
354
  if response.status_code == 200:
355
  st.write("Uploading!")
356
  st.write(response.json())
@@ -359,16 +422,24 @@ with tab2:
359
  del st.session_state[key]
360
  else:
361
  st.write("Error uploading seasonal guillotine aggregate projections")
362
- st.write(response.json())
 
 
 
 
 
 
 
363
  st.cache_data.clear()
364
  for key in st.session_state.keys():
365
  del st.session_state[key]
 
366
  with guillotine_weekly_proj_col:
367
  st.info("Update Weekly Guillotine Projections")
368
  choose_guillotine_weekly_type = st.selectbox("Choose Type", proj_source_options, key='weekly_guillotine_type')
369
  choose_guillotine_weekly_type = proj_replace_options[proj_source_options.index(choose_guillotine_weekly_type)]
370
  if st.button("Update Weekly Guillotine Projections", key='weekly_guillotine_projections'):
371
- response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_guillotine_weekly_type}/weekly/update", headers=headers)
372
  if response.status_code == 200:
373
  st.write("Uploading!")
374
  st.write(response.json())
@@ -377,7 +448,14 @@ with tab2:
377
  del st.session_state[key]
378
  else:
379
  st.write("Error uploading weekly guillotine projections")
380
- st.write(response.json())
 
 
 
 
 
 
 
381
  st.cache_data.clear()
382
  for key in st.session_state.keys():
383
  del st.session_state[key]
@@ -387,7 +465,7 @@ with tab2:
387
  choose_guillotine_ros_type = st.selectbox("Choose Type", ros_source_options, key='rest_of_season_guillotine_type')
388
  choose_guillotine_ros_type = ros_replace_options[ros_source_options.index(choose_guillotine_ros_type)]
389
  if st.button("Update Rest of Season Guillotine Projections", key='rest_of_season_guillotine_projections'):
390
- response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_guillotine_ros_type}/restofseason/update", headers=headers)
391
  if response.status_code == 200:
392
  st.write("Uploading!")
393
  st.write(response.json())
@@ -396,7 +474,14 @@ with tab2:
396
  del st.session_state[key]
397
  else:
398
  st.write("Error uploading rest of season guillotine projections")
399
- st.write(response.json())
 
 
 
 
 
 
 
400
  st.cache_data.clear()
401
  for key in st.session_state.keys():
402
  del st.session_state[key]
@@ -716,7 +801,7 @@ with tab6:
716
  st.header("Update Utilization Report Data")
717
  st.info("Hitting this button will update all UR data (player, season, team styles) across the site")
718
  if st.button("Update Scores", key='scores'):
719
- response = requests.post(f"https://api.fantasylife.com/api/utilization/v1/scores/2025", headers=headers)
720
  if response.status_code == 200:
721
  st.write("Uploading Player Feed!")
722
  st.write(response.json())
@@ -725,14 +810,21 @@ with tab6:
725
  del st.session_state[key]
726
  else:
727
  st.write("Error updating scores")
728
- st.write(response.json())
 
 
 
 
 
 
 
729
  st.cache_data.clear()
730
  for key in st.session_state.keys():
731
  del st.session_state[key]
732
 
733
  time.sleep(3)
734
 
735
- response = requests.post(f"https://api.fantasylife.com/api/utilization/v1/current-season/update", headers=headers)
736
  if response.status_code == 200:
737
  st.write("Uploading Current Season!")
738
  st.write(response.json())
@@ -741,14 +833,21 @@ with tab6:
741
  del st.session_state[key]
742
  else:
743
  st.write("Error updating current season")
744
- st.write(response.json())
 
 
 
 
 
 
 
745
  st.cache_data.clear()
746
  for key in st.session_state.keys():
747
  del st.session_state[key]
748
 
749
  time.sleep(3)
750
 
751
- response = requests.post(f"https://api.fantasylife.com/api/ur-team-styles/v1/current-season/update", headers=headers)
752
  if response.status_code == 200:
753
  st.write("Uploading Team Styles!")
754
  st.write(response.json())
@@ -757,7 +856,14 @@ with tab6:
757
  del st.session_state[key]
758
  else:
759
  st.write("Error updating current season")
760
- st.write(response.json())
 
 
 
 
 
 
 
761
  st.cache_data.clear()
762
  for key in st.session_state.keys():
763
  del st.session_state[key]
@@ -769,17 +875,17 @@ with tab7:
769
  choose_data_source = st.selectbox("Choose Data Source", data_update_options, key='choose_data_source')
770
  if st.button("Update Data", key='site_data_update'):
771
  if choose_data_source == 'DFS':
772
- response = requests.post(f"https://api.fantasylife.com/api/dfs/v1/force-update", headers=headers)
773
  elif choose_data_source == 'DVP':
774
- response = requests.post(f"https://api.fantasylife.com/api/dvp/v1/force-update", headers=headers)
775
  elif choose_data_source == 'Air Yards':
776
- response = requests.post(f"https://api.fantasylife.com/api/air-yards/v1/force-update", headers=headers)
777
  elif choose_data_source == 'FAAB':
778
- response = requests.post(f"https://api.fantasylife.com/api/waivers/v1/force-update", headers=headers)
779
  elif choose_data_source == 'Strength of Sched':
780
- response = requests.post(f"https://api.fantasylife.com/api/sos/v1/force-update", headers=headers)
781
  elif choose_data_source == 'Betting Model':
782
- response = requests.post(f"https://api.fantasylife.com/api/nfl/v1/season/odds/update", headers=headers)
783
  if response.status_code == 200:
784
  st.write("Uploading!")
785
  st.write(response.json())
@@ -788,7 +894,14 @@ with tab7:
788
  del st.session_state[key]
789
  else:
790
  st.write("Error updating site data")
791
- st.write(response.json())
 
 
 
 
 
 
 
792
  st.cache_data.clear()
793
  for key in st.session_state.keys():
794
  del st.session_state[key]
 
166
  choose_seasonal_ranker = st.selectbox("Choose Ranker", name_options, key='seasonal_ranker')
167
  choose_seasonal_ranker = api_replace_options[name_options.index(choose_seasonal_ranker)]
168
  if st.button("Update Seasonal Rankings", key='seasonal_rankings'):
169
+ response = requests.post(f"https://api.fantasylife.com/api/expert-rankings/v1/{choose_seasonal_ranker}/seasonal/update", headers=headers, timeout=60)
170
  if response.status_code == 200:
171
  st.write("Uploading!")
172
  st.write(response.json())
 
175
  del st.session_state[key]
176
  else:
177
  st.write("Error uploading seasonal rankings")
178
+ try:
179
+ if response.text.strip(): # Check if response has content
180
+ st.write(response.json())
181
+ else:
182
+ st.write(f"Empty response. Status code: {response.status_code}")
183
+ except ValueError:
184
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
185
+ st.write(f"Response text: {response.text}")
186
  st.cache_data.clear()
187
  for key in st.session_state.keys():
188
  del st.session_state[key]
 
192
  choose_ros_ranker = st.selectbox("Choose Ranker", name_options, key='rest_of_season_ranker')
193
  choose_ros_ranker = api_replace_options[name_options.index(choose_ros_ranker)]
194
  if st.button("Update Rest of Season Rankings", key='rest_of_season_rankings'):
195
+ response = requests.post(f"https://api.fantasylife.com/api/expert-rankings/v1/{choose_ros_ranker}/restofseason/update", headers=headers, timeout=60)
196
  if response.status_code == 200:
197
  st.write("Uploading!")
198
  st.write(response.json())
 
201
  del st.session_state[key]
202
  else:
203
  st.write("Error uploading rest of season rankings")
204
+ try:
205
+ if response.text.strip(): # Check if response has content
206
+ st.write(response.json())
207
+ else:
208
+ st.write(f"Empty response. Status code: {response.status_code}")
209
+ except ValueError:
210
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
211
+ st.write(f"Response text: {response.text}")
212
  st.cache_data.clear()
213
  for key in st.session_state.keys():
214
  del st.session_state[key]
 
218
  choose_weekly_ranker = st.selectbox("Choose Ranker", name_options, key='weekly_ranker')
219
  choose_weekly_ranker = api_replace_options[name_options.index(choose_weekly_ranker)]
220
  if st.button("Update Weekly Rankings", key='weekly_rankings'):
221
+ response = requests.post(f"https://api.fantasylife.com/api/expert-rankings/v1/{choose_weekly_ranker}/weekly/update", headers=headers, timeout=60)
222
  if response.status_code == 200:
223
  st.write("Uploading!")
224
  st.write(response.json())
 
227
  del st.session_state[key]
228
  else:
229
  st.write("Error uploading weekly rankings")
230
+ try:
231
+ if response.text.strip(): # Check if response has content
232
+ st.write(response.json())
233
+ else:
234
+ st.write(f"Empty response. Status code: {response.status_code}")
235
+ except ValueError:
236
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
237
+ st.write(f"Response text: {response.text}")
238
  st.cache_data.clear()
239
  for key in st.session_state.keys():
240
  del st.session_state[key]
 
248
  choose_seasonal_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='seasonal_guillotine_ranker')
249
  choose_seasonal_guillotine_ranker = api_replace_options[name_options.index(choose_seasonal_guillotine_ranker)]
250
  if st.button("Update Seasonal Guillotine Rankings", key='seasonal_guillotine_rankings'):
251
+ response = requests.post(f"https://api.fantasylife.com/api/guillotine-rankings/v1/{choose_seasonal_guillotine_ranker}/seasonal/update", headers=headers, timeout=60)
252
  if response.status_code == 200:
253
  st.write("Uploading!")
254
  st.write(response.json())
 
257
  del st.session_state[key]
258
  else:
259
  st.write("Error uploading seasonal guillotine rankings")
260
+ try:
261
+ if response.text.strip(): # Check if response has content
262
+ st.write(response.json())
263
+ else:
264
+ st.write(f"Empty response. Status code: {response.status_code}")
265
+ except ValueError:
266
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
267
+ st.write(f"Response text: {response.text}")
268
  st.cache_data.clear()
269
  for key in st.session_state.keys():
270
  del st.session_state[key]
 
274
  choose_rest_of_season_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='rest_of_season_guillotine_ranker')
275
  choose_rest_of_season_guillotine_ranker = api_replace_options[name_options.index(choose_rest_of_season_guillotine_ranker)]
276
  if st.button("Update Rest of Season Guillotine Rankings", key='rest_of_season_guillotine_rankings'):
277
+ response = requests.post(f"https://api.fantasylife.com/api/guillotine-rankings/v1/{choose_rest_of_season_guillotine_ranker}/restofseason/update", headers=headers, timeout=60)
278
  if response.status_code == 200:
279
  st.write("Uploading!")
280
  st.write(response.json())
 
283
  del st.session_state[key]
284
  else:
285
  st.write("Error uploading rest of season guillotine rankings")
286
+ try:
287
+ if response.text.strip(): # Check if response has content
288
+ st.write(response.json())
289
+ else:
290
+ st.write(f"Empty response. Status code: {response.status_code}")
291
+ except ValueError:
292
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
293
+ st.write(f"Response text: {response.text}")
294
  st.cache_data.clear()
295
  for key in st.session_state.keys():
296
  del st.session_state[key]
 
300
  choose_weekly_guillotine_ranker = st.selectbox("Choose Ranker", name_options, key='weekly_guillotine_ranker')
301
  choose_weekly_guillotine_ranker = api_replace_options[name_options.index(choose_weekly_guillotine_ranker)]
302
  if st.button("Update Weekly Guillotine Rankings", key='weekly_guillotine_rankings'):
303
+ response = requests.post(f"https://api.fantasylife.com/api/guillotine-rankings/v1/{choose_weekly_guillotine_ranker}/weekly/update", headers=headers, timeout=60)
304
  if response.status_code == 200:
305
  st.write("Uploading!")
306
  st.write(response.json())
 
309
  del st.session_state[key]
310
  else:
311
  st.write("Error uploading weekly guillotine rankings")
312
+ try:
313
+ if response.text.strip(): # Check if response has content
314
+ st.write(response.json())
315
+ else:
316
+ st.write(f"Empty response. Status code: {response.status_code}")
317
+ except ValueError:
318
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
319
+ st.write(f"Response text: {response.text}")
320
  st.cache_data.clear()
321
  for key in st.session_state.keys():
322
  del st.session_state[key]
 
332
  choose_seasonal_type = st.selectbox("Choose Type", proj_source_options, key='seasonal_type')
333
  choose_seasonal_type = proj_replace_options[proj_source_options.index(choose_seasonal_type)]
334
  if st.button("Update Seasonal Projections", key='seasonal_projections'):
335
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_seasonal_type}/seasonal/update", headers=headers, timeout=60)
336
  if response.status_code == 200:
337
  st.write("Uploading!")
338
  st.write(response.json())
 
341
  del st.session_state[key]
342
  else:
343
  st.write("Error uploading seasonal aggregate projections")
344
+ try:
345
+ if response.text.strip(): # Check if response has content
346
+ st.write(response.json())
347
+ else:
348
+ st.write(f"Empty response. Status code: {response.status_code}")
349
+ except ValueError:
350
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
351
+ st.write(f"Response text: {response.text}")
352
  st.cache_data.clear()
353
  for key in st.session_state.keys():
354
  del st.session_state[key]
 
357
  choose_weekly_type = st.selectbox("Choose Type", proj_source_options, key='weekly_type')
358
  choose_weekly_type = proj_replace_options[proj_source_options.index(choose_weekly_type)]
359
  if st.button("Update Weekly Projections", key='weekly_projections'):
360
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_weekly_type}/weekly/update", headers=headers, timeout=60)
361
  if response.status_code == 200:
362
  st.write("Uploading!")
363
  st.write(response.json())
 
366
  del st.session_state[key]
367
  else:
368
  st.write("Error uploading weekly projections")
369
+ try:
370
+ if response.text.strip(): # Check if response has content
371
+ st.write(response.json())
372
+ else:
373
+ st.write(f"Empty response. Status code: {response.status_code}")
374
+ except ValueError:
375
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
376
+ st.write(f"Response text: {response.text}")
377
  st.cache_data.clear()
378
  for key in st.session_state.keys():
379
  del st.session_state[key]
 
383
  choose_ros_type = st.selectbox("Choose Type", ros_source_options, key='rest_of_season_type')
384
  choose_ros_type = ros_replace_options[ros_source_options.index(choose_ros_type)]
385
  if st.button("Update Rest of Season Projections", key='rest_of_season_projections'):
386
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_ros_type}/restofseason/update", headers=headers, timeout=60)
387
  if response.status_code == 200:
388
  st.write("Uploading!")
389
  st.write(response.json())
 
392
  del st.session_state[key]
393
  else:
394
  st.write("Error uploading rest of season projections")
395
+ try:
396
+ if response.text.strip(): # Check if response has content
397
+ st.write(response.json())
398
+ else:
399
+ st.write(f"Empty response. Status code: {response.status_code}")
400
+ except ValueError:
401
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
402
+ st.write(f"Response text: {response.text}")
403
  st.cache_data.clear()
404
  for key in st.session_state.keys():
405
  del st.session_state[key]
 
413
  choose_guillotine_seasonal_type = st.selectbox("Choose Type", proj_source_options, key='seasonal_guillotine_type')
414
  choose_guillotine_seasonal_type = proj_replace_options[proj_source_options.index(choose_guillotine_seasonal_type)]
415
  if st.button("Update Seasonal Guillotine Projections", key='seasonal_guillotine_projections'):
416
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_guillotine_seasonal_type}/seasonal/update", headers=headers, timeout=60)
417
  if response.status_code == 200:
418
  st.write("Uploading!")
419
  st.write(response.json())
 
422
  del st.session_state[key]
423
  else:
424
  st.write("Error uploading seasonal guillotine aggregate projections")
425
+ try:
426
+ if response.text.strip(): # Check if response has content
427
+ st.write(response.json())
428
+ else:
429
+ st.write(f"Empty response. Status code: {response.status_code}")
430
+ except ValueError:
431
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
432
+ st.write(f"Response text: {response.text}")
433
  st.cache_data.clear()
434
  for key in st.session_state.keys():
435
  del st.session_state[key]
436
+
437
  with guillotine_weekly_proj_col:
438
  st.info("Update Weekly Guillotine Projections")
439
  choose_guillotine_weekly_type = st.selectbox("Choose Type", proj_source_options, key='weekly_guillotine_type')
440
  choose_guillotine_weekly_type = proj_replace_options[proj_source_options.index(choose_guillotine_weekly_type)]
441
  if st.button("Update Weekly Guillotine Projections", key='weekly_guillotine_projections'):
442
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_guillotine_weekly_type}/weekly/update", headers=headers, timeout=60)
443
  if response.status_code == 200:
444
  st.write("Uploading!")
445
  st.write(response.json())
 
448
  del st.session_state[key]
449
  else:
450
  st.write("Error uploading weekly guillotine projections")
451
+ try:
452
+ if response.text.strip(): # Check if response has content
453
+ st.write(response.json())
454
+ else:
455
+ st.write(f"Empty response. Status code: {response.status_code}")
456
+ except ValueError:
457
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
458
+ st.write(f"Response text: {response.text}")
459
  st.cache_data.clear()
460
  for key in st.session_state.keys():
461
  del st.session_state[key]
 
465
  choose_guillotine_ros_type = st.selectbox("Choose Type", ros_source_options, key='rest_of_season_guillotine_type')
466
  choose_guillotine_ros_type = ros_replace_options[ros_source_options.index(choose_guillotine_ros_type)]
467
  if st.button("Update Rest of Season Guillotine Projections", key='rest_of_season_guillotine_projections'):
468
+ response = requests.post(f"https://api.fantasylife.com/api/projections/v1/{choose_guillotine_ros_type}/restofseason/update", headers=headers, timeout=60)
469
  if response.status_code == 200:
470
  st.write("Uploading!")
471
  st.write(response.json())
 
474
  del st.session_state[key]
475
  else:
476
  st.write("Error uploading rest of season guillotine projections")
477
+ try:
478
+ if response.text.strip(): # Check if response has content
479
+ st.write(response.json())
480
+ else:
481
+ st.write(f"Empty response. Status code: {response.status_code}")
482
+ except ValueError:
483
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
484
+ st.write(f"Response text: {response.text}")
485
  st.cache_data.clear()
486
  for key in st.session_state.keys():
487
  del st.session_state[key]
 
801
  st.header("Update Utilization Report Data")
802
  st.info("Hitting this button will update all UR data (player, season, team styles) across the site")
803
  if st.button("Update Scores", key='scores'):
804
+ response = requests.post(f"https://api.fantasylife.com/api/utilization/v1/scores/2025", headers=headers, timeout=60)
805
  if response.status_code == 200:
806
  st.write("Uploading Player Feed!")
807
  st.write(response.json())
 
810
  del st.session_state[key]
811
  else:
812
  st.write("Error updating scores")
813
+ try:
814
+ if response.text.strip(): # Check if response has content
815
+ st.write(response.json())
816
+ else:
817
+ st.write(f"Empty response. Status code: {response.status_code}")
818
+ except ValueError:
819
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
820
+ st.write(f"Response text: {response.text}")
821
  st.cache_data.clear()
822
  for key in st.session_state.keys():
823
  del st.session_state[key]
824
 
825
  time.sleep(3)
826
 
827
+ response = requests.post(f"https://api.fantasylife.com/api/utilization/v1/current-season/update", headers=headers, timeout=60)
828
  if response.status_code == 200:
829
  st.write("Uploading Current Season!")
830
  st.write(response.json())
 
833
  del st.session_state[key]
834
  else:
835
  st.write("Error updating current season")
836
+ try:
837
+ if response.text.strip(): # Check if response has content
838
+ st.write(response.json())
839
+ else:
840
+ st.write(f"Empty response. Status code: {response.status_code}")
841
+ except ValueError:
842
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
843
+ st.write(f"Response text: {response.text}")
844
  st.cache_data.clear()
845
  for key in st.session_state.keys():
846
  del st.session_state[key]
847
 
848
  time.sleep(3)
849
 
850
+ response = requests.post(f"https://api.fantasylife.com/api/ur-team-styles/v1/current-season/update", headers=headers, timeout=60)
851
  if response.status_code == 200:
852
  st.write("Uploading Team Styles!")
853
  st.write(response.json())
 
856
  del st.session_state[key]
857
  else:
858
  st.write("Error updating current season")
859
+ try:
860
+ if response.text.strip(): # Check if response has content
861
+ st.write(response.json())
862
+ else:
863
+ st.write(f"Empty response. Status code: {response.status_code}")
864
+ except ValueError:
865
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
866
+ st.write(f"Response text: {response.text}")
867
  st.cache_data.clear()
868
  for key in st.session_state.keys():
869
  del st.session_state[key]
 
875
  choose_data_source = st.selectbox("Choose Data Source", data_update_options, key='choose_data_source')
876
  if st.button("Update Data", key='site_data_update'):
877
  if choose_data_source == 'DFS':
878
+ response = requests.post(f"https://api.fantasylife.com/api/dfs/v1/force-update", headers=headers, timeout=60)
879
  elif choose_data_source == 'DVP':
880
+ response = requests.post(f"https://api.fantasylife.com/api/dvp/v1/force-update", headers=headers, timeout=60)
881
  elif choose_data_source == 'Air Yards':
882
+ response = requests.post(f"https://api.fantasylife.com/api/air-yards/v1/force-update", headers=headers, timeout=60)
883
  elif choose_data_source == 'FAAB':
884
+ response = requests.post(f"https://api.fantasylife.com/api/waivers/v1/force-update", headers=headers, timeout=60)
885
  elif choose_data_source == 'Strength of Sched':
886
+ response = requests.post(f"https://api.fantasylife.com/api/sos/v1/force-update", headers=headers, timeout=60)
887
  elif choose_data_source == 'Betting Model':
888
+ response = requests.post(f"https://api.fantasylife.com/api/nfl/v1/season/odds/update", headers=headers, timeout=60)
889
  if response.status_code == 200:
890
  st.write("Uploading!")
891
  st.write(response.json())
 
894
  del st.session_state[key]
895
  else:
896
  st.write("Error updating site data")
897
+ try:
898
+ if response.text.strip(): # Check if response has content
899
+ st.write(response.json())
900
+ else:
901
+ st.write(f"Empty response. Status code: {response.status_code}")
902
+ except ValueError:
903
+ st.write(f"Invalid JSON response. Status code: {response.status_code}")
904
+ st.write(f"Response text: {response.text}")
905
  st.cache_data.clear()
906
  for key in st.session_state.keys():
907
  del st.session_state[key]