louiecerv commited on
Commit
b8ae159
1 Parent(s): 6a0b651

Updated the login page

Browse files
Files changed (2) hide show
  1. app.py +28 -13
  2. user_auth.db +0 -0
app.py CHANGED
@@ -92,6 +92,7 @@ def main():
92
  if "authenticated" not in st.session_state:
93
  st.session_state.authenticated = False
94
  st.session_state.username = None
 
95
 
96
  def login_page():
97
  st.title("Login")
@@ -99,11 +100,13 @@ def main():
99
  password = st.text_input("Password", type="password", key="login_password")
100
  if st.button("Login"):
101
  if authenticate_user(username, password):
 
 
102
  st.session_state.authenticated = True
103
  st.session_state.username = username
 
104
  else:
105
  st.error("Invalid username or password.")
106
-
107
  st.write("Don't have an account? [Sign Up](#)")
108
 
109
  def sign_up_page():
@@ -117,7 +120,7 @@ def main():
117
  st.error("Username already exists. Please choose another.")
118
 
119
  def settings_page():
120
- st.title("Manage Your Settings")
121
  username = st.session_state.username
122
  settings = load_settings(username)
123
 
@@ -125,28 +128,40 @@ def main():
125
  topic = st.text_area("Topic", value=settings.get("topic", ""), key="topic")
126
  instructions = st.text_area("Custom Instructions", value=settings.get("instructions", ""), key="instructions")
127
 
128
- if st.button("Save Settings"):
129
- settings = {"topic": topic, "instructions": instructions}
130
- save_settings(username, settings)
131
- st.success("Settings saved successfully!")
132
-
133
  if st.button("Generate Prompt"):
 
 
134
  result = generate_prompt(topic, instructions)
135
  st.success(result)
136
 
137
  # Navigation between pages
138
- st.sidebar.title("Navigation")
139
- page = st.sidebar.radio("Go to", ["Login", "Sign Up", "Settings"])
140
-
141
- if page == "Login":
142
  login_page()
143
- elif page == "Sign Up":
144
  sign_up_page()
145
- elif page == "Settings":
146
  if st.session_state.authenticated:
147
  settings_page()
148
  else:
149
  st.error("You must log in to access this page.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
  if __name__ == "__main__":
152
  main()
 
92
  if "authenticated" not in st.session_state:
93
  st.session_state.authenticated = False
94
  st.session_state.username = None
95
+ st.session_state.page = "Login"
96
 
97
  def login_page():
98
  st.title("Login")
 
100
  password = st.text_input("Password", type="password", key="login_password")
101
  if st.button("Login"):
102
  if authenticate_user(username, password):
103
+ st.success(f"Welcome back, {username}!")
104
+ st.write("Cliok the Go to Settings to run the AI.")
105
  st.session_state.authenticated = True
106
  st.session_state.username = username
107
+ st.session_state.update(page="Main Page")
108
  else:
109
  st.error("Invalid username or password.")
 
110
  st.write("Don't have an account? [Sign Up](#)")
111
 
112
  def sign_up_page():
 
120
  st.error("Username already exists. Please choose another.")
121
 
122
  def settings_page():
123
+ st.title("Chat with Gemini 1.5 flash AI")
124
  username = st.session_state.username
125
  settings = load_settings(username)
126
 
 
128
  topic = st.text_area("Topic", value=settings.get("topic", ""), key="topic")
129
  instructions = st.text_area("Custom Instructions", value=settings.get("instructions", ""), key="instructions")
130
 
 
 
 
 
 
131
  if st.button("Generate Prompt"):
132
+ settings = {"topic": topic, "instructions": instructions}
133
+ save_settings(username, settings)
134
  result = generate_prompt(topic, instructions)
135
  st.success(result)
136
 
137
  # Navigation between pages
138
+ if st.session_state.page == "Login":
 
 
 
139
  login_page()
140
+ elif st.session_state.page == "Sign Up":
141
  sign_up_page()
142
+ elif st.session_state.page == "Main Page":
143
  if st.session_state.authenticated:
144
  settings_page()
145
  else:
146
  st.error("You must log in to access this page.")
147
+ st.session_state.page = "Login"
148
+
149
+ # Sidebar for navigation
150
+ st.sidebar.title("Navigation")
151
+ if st.session_state.authenticated:
152
+ if st.sidebar.button("Go to Main Page"):
153
+ st.session_state.page = "Main Page"
154
+ if st.sidebar.button("Logout"):
155
+ st.session_state.authenticated = False
156
+ st.session_state.username = None
157
+ st.session_state.page = "Login"
158
+ else:
159
+ st.sidebar.radio(
160
+ "Go to",
161
+ ["Login", "Sign Up"],
162
+ key="sidebar_nav",
163
+ on_change=lambda: st.session_state.update(page=st.session_state.sidebar_nav)
164
+ )
165
 
166
  if __name__ == "__main__":
167
  main()
user_auth.db CHANGED
Binary files a/user_auth.db and b/user_auth.db differ