Update app.py
Browse files
app.py
CHANGED
@@ -47,6 +47,8 @@ def main():
|
|
47 |
# Authentication state
|
48 |
if "authenticated" not in st.session_state:
|
49 |
st.session_state.authenticated = False
|
|
|
|
|
50 |
|
51 |
# Central login/register interface
|
52 |
if not st.session_state.authenticated:
|
@@ -80,9 +82,34 @@ def main():
|
|
80 |
|
81 |
# Authenticated user workspace
|
82 |
if st.session_state.authenticated:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
st.subheader(f"Hello, {st.session_state.username}!")
|
84 |
st.write("This is your workspace. All your saved work will appear here.")
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
main()
|
88 |
|
|
|
|
|
|
47 |
# Authentication state
|
48 |
if "authenticated" not in st.session_state:
|
49 |
st.session_state.authenticated = False
|
50 |
+
if "username" not in st.session_state:
|
51 |
+
st.session_state.username = None
|
52 |
|
53 |
# Central login/register interface
|
54 |
if not st.session_state.authenticated:
|
|
|
82 |
|
83 |
# Authenticated user workspace
|
84 |
if st.session_state.authenticated:
|
85 |
+
# Display logout button in the upper-right corner
|
86 |
+
with st.container():
|
87 |
+
st.markdown(
|
88 |
+
"""
|
89 |
+
<style>
|
90 |
+
.logout-button {
|
91 |
+
position: fixed;
|
92 |
+
top: 15px;
|
93 |
+
right: 15px;
|
94 |
+
}
|
95 |
+
</style>
|
96 |
+
""",
|
97 |
+
unsafe_allow_html=True,
|
98 |
+
)
|
99 |
+
if st.button("Log Out", key="logout"):
|
100 |
+
# Show a confirmation dialog
|
101 |
+
if st.button("Confirm Logout"):
|
102 |
+
st.session_state.authenticated = False
|
103 |
+
st.session_state.username = None
|
104 |
+
st.success("You have been logged out.")
|
105 |
+
st.experimental_rerun()
|
106 |
+
|
107 |
+
# Workspace content
|
108 |
st.subheader(f"Hello, {st.session_state.username}!")
|
109 |
st.write("This is your workspace. All your saved work will appear here.")
|
110 |
|
111 |
if __name__ == "__main__":
|
112 |
main()
|
113 |
|
114 |
+
|
115 |
+
|