Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -640,29 +640,29 @@ def update_loe_output(n_clicks, upload_contents, upload_filename, shred_output):
|
|
| 640 |
return "Click 'Generate LOE' to begin."
|
| 641 |
|
| 642 |
try:
|
| 643 |
-
if triggered_id
|
| 644 |
if upload_contents:
|
| 645 |
loe_text, loe_df = generate_loe(upload_contents, is_file=True, filename=upload_filename)
|
| 646 |
elif shred_output:
|
| 647 |
loe_text, loe_df = generate_loe(shred_output)
|
| 648 |
else:
|
| 649 |
return "Please upload a document or complete the Shred tab first."
|
| 650 |
-
else:
|
| 651 |
-
return "Click 'Generate LOE' to begin."
|
| 652 |
|
| 653 |
-
|
| 654 |
-
|
| 655 |
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
|
|
|
|
|
|
| 666 |
except Exception as e:
|
| 667 |
return f"An error occurred: {str(e)}"
|
| 668 |
|
|
|
|
| 640 |
return "Click 'Generate LOE' to begin."
|
| 641 |
|
| 642 |
try:
|
| 643 |
+
if triggered_id in ['generate-loe', 'upload-loe']:
|
| 644 |
if upload_contents:
|
| 645 |
loe_text, loe_df = generate_loe(upload_contents, is_file=True, filename=upload_filename)
|
| 646 |
elif shred_output:
|
| 647 |
loe_text, loe_df = generate_loe(shred_output)
|
| 648 |
else:
|
| 649 |
return "Please upload a document or complete the Shred tab first."
|
|
|
|
|
|
|
| 650 |
|
| 651 |
+
if isinstance(loe_text, str) and loe_text.startswith(("Unsupported file format", "Error processing document", "The document appears to be empty")):
|
| 652 |
+
return loe_text
|
| 653 |
|
| 654 |
+
return [
|
| 655 |
+
dcc.Markdown(loe_text),
|
| 656 |
+
dash_table.DataTable(
|
| 657 |
+
data=loe_df.to_dict('records'),
|
| 658 |
+
columns=[{'name': i, 'id': i} for i in loe_df.columns],
|
| 659 |
+
style_table={'overflowX': 'auto'},
|
| 660 |
+
style_cell={'textAlign': 'left', 'padding': '5px'},
|
| 661 |
+
style_header={'backgroundColor': 'rgb(230, 230, 230)', 'fontWeight': 'bold'}
|
| 662 |
+
)
|
| 663 |
+
]
|
| 664 |
+
else:
|
| 665 |
+
return "Click 'Generate LOE' to begin."
|
| 666 |
except Exception as e:
|
| 667 |
return f"An error occurred: {str(e)}"
|
| 668 |
|