Update app.py
Browse files
app.py
CHANGED
|
@@ -25,10 +25,10 @@ with gr.Blocks(title="DiaSpark: Your Health Management Platform", css=css) as de
|
|
| 25 |
with gr.Row(visible=False) as logged_in_header:
|
| 26 |
welcome_message = gr.Markdown()
|
| 27 |
|
| 28 |
-
# --- Main Tabs
|
| 29 |
with gr.Tabs() as main_tabs:
|
| 30 |
|
| 31 |
-
# --- Tab 1: Homepage ---
|
| 32 |
with gr.TabItem("Home 🏠", id="home_tab"):
|
| 33 |
gr.Markdown(
|
| 34 |
"<h2 class='centered-text'>A Smart First Step in Understanding Your Health</h2>",
|
|
@@ -70,8 +70,8 @@ with gr.Blocks(title="DiaSpark: Your Health Management Platform", css=css) as de
|
|
| 70 |
"""
|
| 71 |
)
|
| 72 |
|
| 73 |
-
# --- Tab 2: Authentication
|
| 74 |
-
with gr.TabItem("Login / Signup 🔑", id="auth_tab"):
|
| 75 |
auth_message = gr.Markdown()
|
| 76 |
|
| 77 |
with gr.Column(visible=True) as login_col:
|
|
@@ -144,7 +144,6 @@ with gr.Blocks(title="DiaSpark: Your Health Management Platform", css=css) as de
|
|
| 144 |
)
|
| 145 |
|
| 146 |
# --- Component Logic (Event Handlers) ---
|
| 147 |
-
# NOTE: No changes are needed in the event handlers for this reordering.
|
| 148 |
|
| 149 |
def switch_to_signup(): return gr.update(visible=False), gr.update(visible=True)
|
| 150 |
def switch_to_login(): return gr.update(visible=True), gr.update(visible=False)
|
|
@@ -156,8 +155,25 @@ with gr.Blocks(title="DiaSpark: Your Health Management Platform", css=css) as de
|
|
| 156 |
is_female = user_data.get("gender") == "Female"
|
| 157 |
username = user_data.get("username", "User")
|
| 158 |
welcome_text = f"### 👋 Welcome, {username}!"
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
signup_btn.click(fn=register, inputs=[email_signup, pwd_signup, gender_signup, username_signup], outputs=[auth_message, email_signup, pwd_signup, gender_signup, username_signup])
|
| 163 |
login_btn.click(fn=login, inputs=[email_login, pwd_login, user_state], outputs=[auth_message, user_state, main_tabs])
|
|
|
|
| 25 |
with gr.Row(visible=False) as logged_in_header:
|
| 26 |
welcome_message = gr.Markdown()
|
| 27 |
|
| 28 |
+
# --- Main Tabs ---
|
| 29 |
with gr.Tabs() as main_tabs:
|
| 30 |
|
| 31 |
+
# --- Tab 1: Homepage (Full Content Restored) ---
|
| 32 |
with gr.TabItem("Home 🏠", id="home_tab"):
|
| 33 |
gr.Markdown(
|
| 34 |
"<h2 class='centered-text'>A Smart First Step in Understanding Your Health</h2>",
|
|
|
|
| 70 |
"""
|
| 71 |
)
|
| 72 |
|
| 73 |
+
# --- Tab 2: Authentication ---
|
| 74 |
+
with gr.TabItem("Login / Signup 🔑", id="auth_tab") as auth_tab_item:
|
| 75 |
auth_message = gr.Markdown()
|
| 76 |
|
| 77 |
with gr.Column(visible=True) as login_col:
|
|
|
|
| 144 |
)
|
| 145 |
|
| 146 |
# --- Component Logic (Event Handlers) ---
|
|
|
|
| 147 |
|
| 148 |
def switch_to_signup(): return gr.update(visible=False), gr.update(visible=True)
|
| 149 |
def switch_to_login(): return gr.update(visible=True), gr.update(visible=False)
|
|
|
|
| 155 |
is_female = user_data.get("gender") == "Female"
|
| 156 |
username = user_data.get("username", "User")
|
| 157 |
welcome_text = f"### 👋 Welcome, {username}!"
|
| 158 |
+
|
| 159 |
+
return (
|
| 160 |
+
gr.update(visible=is_logged_in), # prediction_view
|
| 161 |
+
gr.update(visible=not is_logged_in), # logged_out_view
|
| 162 |
+
gr.update(visible=is_female), # pregnancies_row
|
| 163 |
+
gr.update(value=welcome_text), # welcome_message
|
| 164 |
+
gr.update(visible=is_logged_in), # logged_in_header
|
| 165 |
+
gr.update(visible=not is_logged_in) # auth_tab_item (Show if NOT logged in)
|
| 166 |
+
)
|
| 167 |
+
|
| 168 |
+
user_state.change(
|
| 169 |
+
fn=handle_user_state_change,
|
| 170 |
+
inputs=user_state,
|
| 171 |
+
outputs=[
|
| 172 |
+
prediction_view, logged_out_view, pregnancies_row,
|
| 173 |
+
welcome_message, logged_in_header,
|
| 174 |
+
auth_tab_item
|
| 175 |
+
]
|
| 176 |
+
)
|
| 177 |
|
| 178 |
signup_btn.click(fn=register, inputs=[email_signup, pwd_signup, gender_signup, username_signup], outputs=[auth_message, email_signup, pwd_signup, gender_signup, username_signup])
|
| 179 |
login_btn.click(fn=login, inputs=[email_login, pwd_login, user_state], outputs=[auth_message, user_state, main_tabs])
|