Hoctar77 commited on
Commit
c7c4f68
·
verified ·
1 Parent(s): 2a76450

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -13,13 +13,13 @@ from typing import Dict, List, Any, Tuple, Optional, Pattern, Callable
13
  from dataclasses import dataclass
14
  from functools import wraps
15
  from abc import ABC, abstractmethod
16
- import tempfile # For creating temporary files
17
 
18
  # Third-party imports
19
  import gradio as gr
20
  from docx import Document
21
  from colorama import init, Fore, Style
22
- # from weasyprint import HTML
23
 
24
  # Constants
25
  DEFAULT_PORT = 7860
@@ -2732,7 +2732,6 @@ def create_interface():
2732
  # interactive=False,
2733
  # file_types=[".pdf"]
2734
  # )
2735
-
2736
 
2737
  def process_and_format(file_obj, doc_type_value, template_type_value):
2738
  """Process document and format results as HTML."""
@@ -2743,15 +2742,15 @@ def create_interface():
2743
  file_obj = io.BytesIO(file_obj)
2744
  results_data = checker.run_all_checks(file_obj, doc_type_value, template_type_value)
2745
 
2746
- # Format results using DocumentCheckResultsFormatter
2747
  formatter = DocumentCheckResultsFormatter()
2748
  text_results = formatter.format_results(results_data, doc_type_value)
2749
 
2750
  # Convert to HTML
2751
  html_results = format_results_as_html(text_results)
2752
 
2753
- # Return the HTML results, make the download button visible, and hide the pdf_file component
2754
- return html_results, gr.update(visible=True), gr.update(visible=False)
2755
 
2756
  except Exception as e:
2757
  logging.error(f"Error processing document: {str(e)}")
@@ -2763,8 +2762,7 @@ def create_interface():
2763
  Please ensure the file is a valid .docx document and try again.
2764
  </div>
2765
  """
2766
- # Return only the HTML results
2767
- return error_html, gr.update(visible=False), gr.update(visible=False)
2768
 
2769
  # Update template type visibility based on document type
2770
  def update_template_visibility(doc_type_value):
 
13
  from dataclasses import dataclass
14
  from functools import wraps
15
  from abc import ABC, abstractmethod
16
+ # import tempfile # For creating temporary files
17
 
18
  # Third-party imports
19
  import gradio as gr
20
  from docx import Document
21
  from colorama import init, Fore, Style
22
+ # from weasyprint import HTML # PDF generation related import
23
 
24
  # Constants
25
  DEFAULT_PORT = 7860
 
2732
  # interactive=False,
2733
  # file_types=[".pdf"]
2734
  # )
 
2735
 
2736
  def process_and_format(file_obj, doc_type_value, template_type_value):
2737
  """Process document and format results as HTML."""
 
2742
  file_obj = io.BytesIO(file_obj)
2743
  results_data = checker.run_all_checks(file_obj, doc_type_value, template_type_value)
2744
 
2745
+ # Format results using DocumentCheckResultsFormatter
2746
  formatter = DocumentCheckResultsFormatter()
2747
  text_results = formatter.format_results(results_data, doc_type_value)
2748
 
2749
  # Convert to HTML
2750
  html_results = format_results_as_html(text_results)
2751
 
2752
+ # Return only the HTML results
2753
+ return html_results
2754
 
2755
  except Exception as e:
2756
  logging.error(f"Error processing document: {str(e)}")
 
2762
  Please ensure the file is a valid .docx document and try again.
2763
  </div>
2764
  """
2765
+ return error_html
 
2766
 
2767
  # Update template type visibility based on document type
2768
  def update_template_visibility(doc_type_value):