Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1183,19 +1183,19 @@ with gr.Blocks(title=APP_NAME) as demo:
|
|
| 1183 |
|
| 1184 |
save_status = gr.Markdown("")
|
| 1185 |
|
| 1186 |
-
# RIGHT COLUMN: RESULTS
|
| 1187 |
-
with gr.Column(scale=1, min_width=350):
|
| 1188 |
-
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
|
| 1200 |
# ============================================================
|
| 1201 |
# BENCHMARK SECTION
|
|
@@ -1232,60 +1232,61 @@ with gr.Column(scale=1, min_width=350):
|
|
| 1232 |
wrap=True,
|
| 1233 |
)
|
| 1234 |
|
| 1235 |
-
|
| 1236 |
-
# ADMIN-ONLY ANALYTICS TAB
|
| 1237 |
-
# ============================================================
|
| 1238 |
-
|
| 1239 |
-
with gr.TabItem("π Admin"):
|
| 1240 |
-
gr.Markdown("### π Admin Dashboard")
|
| 1241 |
-
|
| 1242 |
-
with gr.Group(elem_classes="admin-login"):
|
| 1243 |
-
gr.Markdown("Enter admin password to view analytics and download data.")
|
| 1244 |
|
| 1245 |
-
with gr.
|
| 1246 |
-
|
| 1247 |
-
|
| 1248 |
-
|
| 1249 |
-
|
| 1250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1251 |
)
|
| 1252 |
-
|
| 1253 |
-
logout_btn
|
| 1254 |
-
|
| 1255 |
-
|
| 1256 |
-
|
| 1257 |
-
|
| 1258 |
-
|
| 1259 |
-
|
| 1260 |
-
|
| 1261 |
-
|
| 1262 |
-
|
| 1263 |
-
|
| 1264 |
-
|
| 1265 |
-
|
| 1266 |
-
|
| 1267 |
-
|
| 1268 |
-
|
| 1269 |
-
|
| 1270 |
-
|
| 1271 |
-
|
| 1272 |
-
logout_btn.click(
|
| 1273 |
-
fn=logout_admin,
|
| 1274 |
-
inputs=[],
|
| 1275 |
-
outputs=[admin_output, admin_password_input, logout_btn],
|
| 1276 |
-
)
|
| 1277 |
-
|
| 1278 |
-
export_leads_btn.click(
|
| 1279 |
-
fn=export_leads_wrapper,
|
| 1280 |
-
inputs=[],
|
| 1281 |
-
outputs=[export_leads_output],
|
| 1282 |
-
)
|
| 1283 |
-
|
| 1284 |
-
export_calc_btn.click(
|
| 1285 |
-
fn=export_calculations_wrapper,
|
| 1286 |
-
inputs=[],
|
| 1287 |
-
outputs=[export_calc_output],
|
| 1288 |
-
)
|
| 1289 |
# ============================================================
|
| 1290 |
# BREED REFERENCE
|
| 1291 |
# ============================================================
|
|
@@ -1411,5 +1412,5 @@ if __name__ == "__main__":
|
|
| 1411 |
demo.launch(
|
| 1412 |
server_name="0.0.0.0",
|
| 1413 |
server_port=port,
|
| 1414 |
-
ssr_mode=False
|
| 1415 |
)
|
|
|
|
| 1183 |
|
| 1184 |
save_status = gr.Markdown("")
|
| 1185 |
|
| 1186 |
+
# RIGHT COLUMN: RESULTS
|
| 1187 |
+
with gr.Column(scale=1, min_width=350):
|
| 1188 |
+
gr.Markdown("## π― Quick Answer")
|
| 1189 |
+
result = gr.HTML(
|
| 1190 |
+
value="""
|
| 1191 |
+
<div style="font-size: 16px; color: #9ca3af; text-align: center; padding: 40px 20px;">
|
| 1192 |
+
<div style="font-size: 48px; margin-bottom: 12px;">π</div>
|
| 1193 |
+
<div>Select your breed, enter details and click <strong>Calculate</strong></div>
|
| 1194 |
+
<div style="font-size: 14px; margin-top: 8px;">Your feed estimate will appear here</div>
|
| 1195 |
+
</div>
|
| 1196 |
+
""",
|
| 1197 |
+
elem_classes=["answer-box"],
|
| 1198 |
+
)
|
| 1199 |
|
| 1200 |
# ============================================================
|
| 1201 |
# BENCHMARK SECTION
|
|
|
|
| 1232 |
wrap=True,
|
| 1233 |
)
|
| 1234 |
|
| 1235 |
+
# ============================================================
|
| 1236 |
+
# ADMIN-ONLY ANALYTICS TAB
|
| 1237 |
+
# ============================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1238 |
|
| 1239 |
+
with gr.TabItem("π Admin"):
|
| 1240 |
+
gr.Markdown("### π Admin Dashboard")
|
| 1241 |
+
|
| 1242 |
+
with gr.Group(elem_classes="admin-login"):
|
| 1243 |
+
gr.Markdown("Enter admin password to view analytics and download data.")
|
| 1244 |
+
|
| 1245 |
+
with gr.Row():
|
| 1246 |
+
admin_password_input = gr.Textbox(
|
| 1247 |
+
label="Admin Password",
|
| 1248 |
+
placeholder="Enter password...",
|
| 1249 |
+
type="password",
|
| 1250 |
+
scale=2,
|
| 1251 |
+
)
|
| 1252 |
+
login_btn = gr.Button("Login", variant="primary", scale=1)
|
| 1253 |
+
logout_btn = gr.Button("Logout", variant="secondary", scale=1)
|
| 1254 |
+
|
| 1255 |
+
admin_output = gr.Markdown("π Enter password to view analytics.")
|
| 1256 |
+
|
| 1257 |
+
with gr.Row():
|
| 1258 |
+
export_leads_btn = gr.Button("π₯ Export Leads (CSV)", variant="secondary")
|
| 1259 |
+
export_leads_output = gr.File(label="Download Leads CSV")
|
| 1260 |
+
|
| 1261 |
+
with gr.Row():
|
| 1262 |
+
export_calc_btn = gr.Button("π₯ Export Calculations (CSV)", variant="secondary")
|
| 1263 |
+
export_calc_output = gr.File(label="Download Calculations CSV")
|
| 1264 |
+
|
| 1265 |
+
# Login/Logout events
|
| 1266 |
+
login_btn.click(
|
| 1267 |
+
fn=admin_login,
|
| 1268 |
+
inputs=[admin_password_input],
|
| 1269 |
+
outputs=[admin_output, admin_password_input, logout_btn],
|
| 1270 |
)
|
| 1271 |
+
|
| 1272 |
+
logout_btn.click(
|
| 1273 |
+
fn=logout_admin,
|
| 1274 |
+
inputs=[],
|
| 1275 |
+
outputs=[admin_output, admin_password_input, logout_btn],
|
| 1276 |
+
)
|
| 1277 |
+
|
| 1278 |
+
export_leads_btn.click(
|
| 1279 |
+
fn=export_leads_wrapper,
|
| 1280 |
+
inputs=[],
|
| 1281 |
+
outputs=[export_leads_output],
|
| 1282 |
+
)
|
| 1283 |
+
|
| 1284 |
+
export_calc_btn.click(
|
| 1285 |
+
fn=export_calculations_wrapper,
|
| 1286 |
+
inputs=[],
|
| 1287 |
+
outputs=[export_calc_output],
|
| 1288 |
+
)
|
| 1289 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1290 |
# ============================================================
|
| 1291 |
# BREED REFERENCE
|
| 1292 |
# ============================================================
|
|
|
|
| 1412 |
demo.launch(
|
| 1413 |
server_name="0.0.0.0",
|
| 1414 |
server_port=port,
|
| 1415 |
+
ssr_mode=False
|
| 1416 |
)
|