File size: 1,207 Bytes
dd64f21 d16c97d 050fd9f b7f1486 5e815e0 ddb39cb dd64f21 0128ae2 dd64f21 773f7ef dd64f21 720467c b7f1486 45f646a ed0fd3f 050fd9f ed0fd3f 720467c 050fd9f dd64f21 d16c97d 050fd9f 720467c |
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 |
import os
import streamlit as st
from queries.nflverse.github_data import load_assets
from queries.supabase_db.client import get_new_supabase_client
from data_storage import login_by_token
def get_local_style():
code_str = ""
css_dir = os.path.join(os.path.dirname(__file__), "css")
for css_file in os.listdir(css_dir):
with open(os.path.join(css_dir, css_file)) as f:
code_str += "<style>{}</style>".format(f.read())
code_str += "\n"
return code_str
def local_css():
st.markdown(get_local_style(), unsafe_allow_html=True)
def login_token_arg_if_exists():
url_params = st.query_params
if arg_token := url_params.get("token"):
try:
login_by_token(arg_token, st.session_state["db_client"])
except Exception:
st.write("Sorry, error logging in. Please refresh to try again.")
st.stop()
def set_session_db_client():
session_db_key = "db_client"
if not st.session_state.get(session_db_key):
st.session_state[session_db_key] = get_new_supabase_client()
def common_page_config():
local_css()
load_assets()
set_session_db_client()
login_token_arg_if_exists()
|