-
Notifications
You must be signed in to change notification settings - Fork 1
/
Home.py
79 lines (62 loc) · 2.18 KB
/
Home.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import streamlit as st
import streamlit_authenticator as stauth
import yaml
from dotenv import load_dotenv
from st_pages import Page, Section, add_indentation, show_pages
from utils.data import init_connection
from utils.utils import hide_streamlit_elements
load_dotenv()
hide_streamlit_elements()
def init_login():
with open("login.yaml") as file:
config = yaml.load(file, Loader=yaml.SafeLoader)
authenticator = stauth.Authenticate(
config["credentials"],
config["cookie"]["name"],
config["cookie"]["key"],
config["cookie"]["expiry_days"],
[],
)
return authenticator
def config_pages():
add_indentation()
show_pages(
[
Page("Home.py", "Home", "🏠"),
Section("League", "⚽️"),
Page("pages_experimental/1_Teams.py", "Teams", "👥"),
Page("pages_experimental/2_Matches.py", "Matches", "📅"),
Page("pages_experimental/3_Match_details.py", "Match details", "📊"),
Page("pages_experimental/4_Statistics.py", "Statistics", "🏅"),
Page("pages_experimental/5_Standings.py", "Standings", "🏆"),
Section("Admin", "🔒"),
Page(
"pages_experimental/6_Edit_match_details.py",
"Edit match details",
"⚙️",
),
Page(
"pages_experimental/7_Edit_player_details.py",
"Edit player details",
"🔧",
),
]
)
def main():
config_pages()
db = init_connection()
st.session_state["db"] = db
reload_data_btn = st.button("Reload data")
if reload_data_btn:
st.experimental_singleton.clear()
st.write("# Home page")
st.write("#### Welcome to the BFF dashboard")
authenticator = init_login()
authenticator.login("Admin login", "main")
if st.session_state["authentication_status"]:
st.write(f'Connected as *{st.session_state["name"]}*')
authenticator.logout("Logout", "main")
elif st.session_state["authentication_status"] is False:
st.error("Username or password is incorrect")
if __name__ == "__main__":
main()