HarshitX commited on
Commit
bbb7f45
·
verified ·
1 Parent(s): e8e6d44

Added logout functionality.

Browse files
Files changed (1) hide show
  1. app.py +21 -15
app.py CHANGED
@@ -158,6 +158,12 @@ def signup():
158
  else:
159
  st.warning("Passwords do not match.")
160
 
 
 
 
 
 
 
161
  def marketplace(username):
162
  # Custom CSS for better aesthetics
163
  st.markdown("""
@@ -275,23 +281,23 @@ def marketplace(username):
275
  st.markdown("Created with ❤️ by Harshit S | © 2024 PDF Reader App")
276
 
277
  def main():
278
- st.title("Choose the suitable category:")
 
279
 
280
- if "logged_in" not in st.session_state:
281
- st.session_state.logged_in = False
 
 
 
 
 
 
 
 
282
 
283
- if st.session_state.logged_in:
284
- marketplace(st.session_state.username)
285
- else:
286
- menu = ["Login", "Sign Up"]
287
- choice = st.sidebar.selectbox("Menu", menu)
288
-
289
- if choice == "Login":
290
- call = login()
291
- if call:
292
- main()
293
- elif choice == "Sign Up":
294
- signup()
295
 
296
  if __name__ == "__main__":
297
  print(peek())
 
158
  else:
159
  st.warning("Passwords do not match.")
160
 
161
+ def logout():
162
+ for key in list(st.session_state.keys()):
163
+ del st.session_state[key]
164
+ st.session_state.logged_out = True
165
+ st.rerun()
166
+
167
  def marketplace(username):
168
  # Custom CSS for better aesthetics
169
  st.markdown("""
 
281
  st.markdown("Created with ❤️ by Harshit S | © 2024 PDF Reader App")
282
 
283
  def main():
284
+ if 'logged_in' not in st.session_state:
285
+ st.session_state.logged_in = False
286
 
287
+ if st.session_state.logged_in:
288
+ marketplace(st.session_state.username)
289
+ else:
290
+ st.title("Welcome to AI Chat")
291
+ choice = st.selectbox("Login/Signup", ["Login", "Sign Up"])
292
+
293
+ if choice == "Login":
294
+ login()
295
+ else:
296
+ signup()
297
 
298
+ if st.session_state.get('logged_out', False):
299
+ st.info("You have been logged out successfully.")
300
+ st.session_state.logged_out = False
 
 
 
 
 
 
 
 
 
301
 
302
  if __name__ == "__main__":
303
  print(peek())