generated from streamlit/blank-app-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_app.py
65 lines (45 loc) · 2.18 KB
/
streamlit_app.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import streamlit as st
import requests
import pandas as pd
import datetime
from PIL import Image
from io import BytesIO
import base64
from streamlit_autorefresh import st_autorefresh as autoref
from getdata import getteamdata, getcompetitions, getschedule, getteamrank, displayteamdata, displayschedule, gettopteams, displayrankings, getdistrictrank, getawards
st.set_page_config(page_title="FRC Display", page_icon=Image.open("FRCdisplayicon.png"), layout="centered", initial_sidebar_state="expanded", menu_items=None)
st.logo(Image.open("FRCexpandedicon.png"), size="large", icon_image=Image.open("FRCdisplayicon.png"))
token = st.secrets['TOKEN']
st.title("FRC Display")
year = str(datetime.datetime.now().year)
team = st.sidebar.text_input("Team Number",
value=(st.query_params.team if "team" in st.query_params else None),
placeholder="1234")
if team:
st.query_params.team = team
districtcode, rookieyear, teamavatar = getteamdata(team, year)
st.logo(Image.open("FRCexpandedicon.png"), size="large", icon_image=teamavatar)
if rookieyear:
currentevents = []
events = []
currentevent, eventinfo, events, currentevents = getcompetitions(team, year)
level_list = ["Qualification", "Playoff"]
levelindex = level_list.index(st.query_params.level) if "level" in st.query_params else 0
level = st.sidebar.selectbox("Level:", level_list, index=levelindex)
if level:
st.query_params.level = level
if currentevent and level:
rankdata = getteamrank(team, year, currentevent, level)
scheduledf, teamrp = getschedule(team, year, currentevent, level)
displayteamdata(rankdata, teamrp)
displayschedule(team, eventinfo, scheduledf)
rankingdf = gettopteams(team, year, currentevent, level)
displayrankings(team, rankingdf)
getdistrictrank(team, year, districtcode, events, currentevents)
getawards(team, year, rookieyear)
else:
st.write(f"Team **{team}** does not exist.")
checkbox = st.sidebar.checkbox("Auto Refresh?", value=st.query_params.refresh if "refresh" in st.query_params else 0)
if checkbox:
autoref(interval=60000)
st.query_params.refresh = checkbox