Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -545,6 +545,12 @@ def analyze_prospects_data(file_path):
|
|
| 545 |
logger.error(f"Error analyzing data: {e}")
|
| 546 |
return create_error_message(f"Analysis failed: {str(e)}"), None, None, None
|
| 547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
|
| 549 |
def handle_file_upload(file):
|
| 550 |
"""Handle file upload and analysis - automatically analyze when file is uploaded"""
|
|
@@ -554,13 +560,13 @@ def handle_file_upload(file):
|
|
| 554 |
|
| 555 |
# Gradio interface with light theme
|
| 556 |
css = """
|
| 557 |
-
|
| 558 |
.metric-container {
|
| 559 |
display: flex;
|
| 560 |
justify-content: space-around;
|
| 561 |
margin: 20px 0;
|
| 562 |
}
|
| 563 |
"""
|
|
|
|
| 564 |
# JavaScript to force light theme
|
| 565 |
js = """
|
| 566 |
function refresh() {
|
|
@@ -572,8 +578,6 @@ function refresh() {
|
|
| 572 |
}
|
| 573 |
"""
|
| 574 |
|
| 575 |
-
|
| 576 |
-
|
| 577 |
# Create the Gradio interface with light theme
|
| 578 |
with gr.Blocks(css=css, js=js, theme=gr.themes.Soft()) as demo:
|
| 579 |
gr.Markdown("""
|
|
@@ -615,7 +619,12 @@ with gr.Blocks(css=css, js=js, theme=gr.themes.Soft()) as demo:
|
|
| 615 |
outputs=[r2_output, avg_target_output, factor_performance_plot, driver_analysis_plot]
|
| 616 |
)
|
| 617 |
|
| 618 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 619 |
|
| 620 |
# Launch the demo
|
| 621 |
demo.launch(server_name="0.0.0.0", share=False)
|
|
|
|
| 545 |
logger.error(f"Error analyzing data: {e}")
|
| 546 |
return create_error_message(f"Analysis failed: {str(e)}"), None, None, None
|
| 547 |
|
| 548 |
+
def load_default_file():
|
| 549 |
+
"""Load default file on startup"""
|
| 550 |
+
default_file = "example_files/Volkswagen Non Customers.xlsx"
|
| 551 |
+
if os.path.exists(default_file):
|
| 552 |
+
return analyze_prospects_data(default_file)
|
| 553 |
+
return create_placeholder_message(), None, None, None
|
| 554 |
|
| 555 |
def handle_file_upload(file):
|
| 556 |
"""Handle file upload and analysis - automatically analyze when file is uploaded"""
|
|
|
|
| 560 |
|
| 561 |
# Gradio interface with light theme
|
| 562 |
css = """
|
|
|
|
| 563 |
.metric-container {
|
| 564 |
display: flex;
|
| 565 |
justify-content: space-around;
|
| 566 |
margin: 20px 0;
|
| 567 |
}
|
| 568 |
"""
|
| 569 |
+
|
| 570 |
# JavaScript to force light theme
|
| 571 |
js = """
|
| 572 |
function refresh() {
|
|
|
|
| 578 |
}
|
| 579 |
"""
|
| 580 |
|
|
|
|
|
|
|
| 581 |
# Create the Gradio interface with light theme
|
| 582 |
with gr.Blocks(css=css, js=js, theme=gr.themes.Soft()) as demo:
|
| 583 |
gr.Markdown("""
|
|
|
|
| 619 |
outputs=[r2_output, avg_target_output, factor_performance_plot, driver_analysis_plot]
|
| 620 |
)
|
| 621 |
|
| 622 |
+
# Auto-load default file on page load
|
| 623 |
+
demo.load(
|
| 624 |
+
fn=load_default_file,
|
| 625 |
+
inputs=[],
|
| 626 |
+
outputs=[r2_output, avg_target_output, factor_performance_plot, driver_analysis_plot]
|
| 627 |
+
)
|
| 628 |
|
| 629 |
# Launch the demo
|
| 630 |
demo.launch(server_name="0.0.0.0", share=False)
|