Spaces:
Starting
Starting
Update app.py
Browse files
app.py
CHANGED
@@ -19,13 +19,13 @@ login(token=os.environ.get("HF_TOKEN"), write_permission=True)
|
|
19 |
AUTHENTICATOR = None
|
20 |
TBYB_LOGO = Image.open('./assets/TBYB_logo_light.png')
|
21 |
USER_LOGGED_IN = False
|
22 |
-
|
23 |
|
24 |
|
25 |
USER_DATABASE_DIR = Path("user_database")
|
26 |
USER_DATABASE_DIR.mkdir(parents=True, exist_ok=True)
|
27 |
|
28 |
-
USER_DATABASE_PATH = USER_DATABASE_DIR / f"tbyb-users-{uuid4()}.
|
29 |
|
30 |
USER_DATABASE_UPDATE_SCHEDULER = CommitScheduler(
|
31 |
repo_id="try-before-you-bias-data",
|
@@ -79,6 +79,8 @@ def user_login_create():
|
|
79 |
global TBYB_LOGO
|
80 |
global USER_LOGGED_IN
|
81 |
users = None
|
|
|
|
|
82 |
with open(USER_DATABASE_PATH) as file:
|
83 |
users = yaml.load(file, Loader=SafeLoader)
|
84 |
AUTHENTICATOR = stauth.Authenticate(
|
@@ -88,6 +90,7 @@ def user_login_create():
|
|
88 |
users['cookie']['expiry_days'],
|
89 |
users['preauthorized']
|
90 |
)
|
|
|
91 |
with st.sidebar:
|
92 |
st.image(TBYB_LOGO, width=70)
|
93 |
loginTab, registerTab, detailsTab = st.tabs(["Log in", "Register", "Account details"])
|
|
|
19 |
AUTHENTICATOR = None
|
20 |
TBYB_LOGO = Image.open('./assets/TBYB_logo_light.png')
|
21 |
USER_LOGGED_IN = False
|
22 |
+
base_user_database_path = './data/user_database.yaml'
|
23 |
|
24 |
|
25 |
USER_DATABASE_DIR = Path("user_database")
|
26 |
USER_DATABASE_DIR.mkdir(parents=True, exist_ok=True)
|
27 |
|
28 |
+
USER_DATABASE_PATH = USER_DATABASE_DIR / f"tbyb-users-{uuid4()}.yaml"
|
29 |
|
30 |
USER_DATABASE_UPDATE_SCHEDULER = CommitScheduler(
|
31 |
repo_id="try-before-you-bias-data",
|
|
|
79 |
global TBYB_LOGO
|
80 |
global USER_LOGGED_IN
|
81 |
users = None
|
82 |
+
if not os.path.exists(USER_DATABASE_PATH):
|
83 |
+
USER_DATABASE_PATH=base_user_database_path
|
84 |
with open(USER_DATABASE_PATH) as file:
|
85 |
users = yaml.load(file, Loader=SafeLoader)
|
86 |
AUTHENTICATOR = stauth.Authenticate(
|
|
|
90 |
users['cookie']['expiry_days'],
|
91 |
users['preauthorized']
|
92 |
)
|
93 |
+
|
94 |
with st.sidebar:
|
95 |
st.image(TBYB_LOGO, width=70)
|
96 |
loginTab, registerTab, detailsTab = st.tabs(["Log in", "Register", "Account details"])
|