Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -378,7 +378,7 @@ class SocialMediaAnalyzer:
|
|
| 378 |
}
|
| 379 |
result = self.unified_service.predict_conflicts(input_data)
|
| 380 |
if 'error' in result:
|
| 381 |
-
return f"β Error: {result['error']}"
|
| 382 |
|
| 383 |
# Create the pie chart
|
| 384 |
pie_chart_img = create_conflict_pie_chart(result)
|
|
@@ -423,7 +423,7 @@ class SocialMediaAnalyzer:
|
|
| 423 |
}
|
| 424 |
result = self.unified_service.predict_addicted_score(input_data)
|
| 425 |
if 'error' in result:
|
| 426 |
-
return f"β Error: {result['error']}"
|
| 427 |
|
| 428 |
# Create only the gauge chart
|
| 429 |
gauge_img = create_addiction_gauge_chart(result)
|
|
@@ -471,7 +471,7 @@ class SocialMediaAnalyzer:
|
|
| 471 |
}
|
| 472 |
result = self.unified_service.predict_cluster(input_data)
|
| 473 |
if 'error' in result:
|
| 474 |
-
return f"β Error: {result['error']}"
|
| 475 |
|
| 476 |
# Get real clustering assignments for all data
|
| 477 |
cluster_df = self.get_clustering_assignments()
|
|
@@ -662,5 +662,23 @@ if __name__ == "__main__":
|
|
| 662 |
# Create and launch the app
|
| 663 |
app = create_interface()
|
| 664 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 665 |
|
| 666 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
}
|
| 379 |
result = self.unified_service.predict_conflicts(input_data)
|
| 380 |
if 'error' in result:
|
| 381 |
+
return f"""β Error: {result['error']}\n\nTraceback:\n{result.get('traceback', '')}"""
|
| 382 |
|
| 383 |
# Create the pie chart
|
| 384 |
pie_chart_img = create_conflict_pie_chart(result)
|
|
|
|
| 423 |
}
|
| 424 |
result = self.unified_service.predict_addicted_score(input_data)
|
| 425 |
if 'error' in result:
|
| 426 |
+
return f"""β Error: {result['error']}\n\nTraceback:\n{result.get('traceback', '')}"""
|
| 427 |
|
| 428 |
# Create only the gauge chart
|
| 429 |
gauge_img = create_addiction_gauge_chart(result)
|
|
|
|
| 471 |
}
|
| 472 |
result = self.unified_service.predict_cluster(input_data)
|
| 473 |
if 'error' in result:
|
| 474 |
+
return f"""β Error: {result['error']}\n\nTraceback:\n{result.get('traceback', '')}"""
|
| 475 |
|
| 476 |
# Get real clustering assignments for all data
|
| 477 |
cluster_df = self.get_clustering_assignments()
|
|
|
|
| 662 |
# Create and launch the app
|
| 663 |
app = create_interface()
|
| 664 |
|
| 665 |
+
# Launch with automatic port finding
|
| 666 |
+
import socket
|
| 667 |
+
def find_free_port():
|
| 668 |
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
| 669 |
+
s.bind(('', 0))
|
| 670 |
+
s.listen(1)
|
| 671 |
+
port = s.getsockname()[1]
|
| 672 |
+
return port
|
| 673 |
|
| 674 |
+
port = find_free_port()
|
| 675 |
+
print(f"π Launching app on port {port}")
|
| 676 |
+
print(f"π± Access the app at: http://localhost:{port}")
|
| 677 |
+
|
| 678 |
+
app.launch(
|
| 679 |
+
server_name="0.0.0.0",
|
| 680 |
+
server_port=port,
|
| 681 |
+
share=False,
|
| 682 |
+
show_error=True,
|
| 683 |
+
quiet=False
|
| 684 |
+
)
|