Spaces:
Build error
Build error
Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from dashboard_components import dashboard_header, account_linking_form, apply_custom_css
|
| 3 |
+
from utils.security import clear_metrics
|
| 4 |
+
|
| 5 |
+
def logout_user():
|
| 6 |
+
"""Properly handle user logout."""
|
| 7 |
+
try:
|
| 8 |
+
# Clear metrics before session cleanup
|
| 9 |
+
clear_metrics()
|
| 10 |
+
# Clear session state
|
| 11 |
+
st.session_state.clear()
|
| 12 |
+
# Rerun the app
|
| 13 |
+
st.rerun()
|
| 14 |
+
except Exception as e:
|
| 15 |
+
st.error(f"Logout error: {str(e)}")
|
| 16 |
+
|
| 17 |
+
def main():
|
| 18 |
+
"""Main application entry point."""
|
| 19 |
+
# Initialize session state
|
| 20 |
+
if 'page' not in st.session_state:
|
| 21 |
+
st.session_state.page = 'login'
|
| 22 |
+
|
| 23 |
+
# Apply custom CSS
|
| 24 |
+
apply_custom_css()
|
| 25 |
+
|
| 26 |
+
# Show different pages based on state
|
| 27 |
+
if st.session_state.page == 'login':
|
| 28 |
+
show_login_page()
|
| 29 |
+
elif st.session_state.page == 'dashboard':
|
| 30 |
+
# Show header with proper logout callback
|
| 31 |
+
dashboard_header(logout_callback=logout_user)
|
| 32 |
+
show_dashboard()
|
| 33 |
+
elif st.session_state.page == 'link_accounts':
|
| 34 |
+
dashboard_header(logout_callback=logout_user)
|
| 35 |
+
account_linking_form()
|
| 36 |
+
elif st.session_state.page == 'wallets':
|
| 37 |
+
dashboard_header(logout_callback=logout_user)
|
| 38 |
+
show_wallets_page()
|
| 39 |
+
|
| 40 |
+
if __name__ == "__main__":
|
| 41 |
+
main()
|