DS2 commited on
Commit
f97a1a6
·
verified ·
1 Parent(s): 9b06de2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -23
app.py CHANGED
@@ -22,29 +22,24 @@ def load_lottieurl(url: str):
22
  # Load the Lottie animation
23
  lottie_hello = load_lottieurl("https://lottie.host/d29edbdd-af94-402e-bb4c-b314f17897e6/n5SKHOkbYQ.json")
24
 
25
- # Function to display the login form in the main area, not sidebar
26
- def login():
27
- login_container = st.empty()
28
- with login_container.container():
29
- st.header("Enter Password to Continue")
30
- password = st.text_input("Password", type="password", key="password_input")
31
- if st.button("Submit"):
32
- if password == APP_PASSWORD:
33
- st.session_state["authenticated"] = True
34
- login_container.empty()
35
- st.success("Authentication successful!")
36
- else:
37
- st.error("Incorrect password")
38
-
39
- # Main app logic
40
- if "authenticated" not in st.session_state:
41
- st.session_state["authenticated"] = False
42
-
43
- if not st.session_state["authenticated"]:
44
- login()
45
 
46
- if st.session_state["authenticated"]:
47
- # Rest of your app code here (unchanged)
 
 
 
 
 
 
 
 
 
 
 
 
48
  # Custom styles with the background image and updated shadow effect
49
  st.markdown(
50
  """
@@ -150,4 +145,10 @@ if st.session_state["authenticated"]:
150
  height=150,
151
  width=150,
152
  key=None,
153
- )
 
 
 
 
 
 
 
22
  # Load the Lottie animation
23
  lottie_hello = load_lottieurl("https://lottie.host/d29edbdd-af94-402e-bb4c-b314f17897e6/n5SKHOkbYQ.json")
24
 
25
+ # Initialize session state
26
+ if 'authenticated' not in st.session_state:
27
+ st.session_state['authenticated'] = False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
+ # Function to handle login
30
+ def login():
31
+ st.header("Enter Password to Continue")
32
+ password = st.text_input("Password", type="password", key="password_input")
33
+ if st.button("Submit"):
34
+ if password == APP_PASSWORD:
35
+ st.session_state['authenticated'] = True
36
+ st.success("Authentication successful!")
37
+ st.rerun()
38
+ else:
39
+ st.error("Incorrect password")
40
+
41
+ # Main app content
42
+ def main_content():
43
  # Custom styles with the background image and updated shadow effect
44
  st.markdown(
45
  """
 
145
  height=150,
146
  width=150,
147
  key=None,
148
+ )
149
+
150
+ # Main app logic
151
+ if not st.session_state['authenticated']:
152
+ login()
153
+ else:
154
+ main_content()