Gabriel commited on
Commit
753cdf9
·
verified ·
1 Parent(s): c6b50f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -14
app.py CHANGED
@@ -193,25 +193,15 @@ def htrflow_htr_url(image_path: str, document_type: Literal["letter_english", "l
193
  break
194
 
195
  if output_file_path and os.path.exists(output_file_path):
196
- # Read the file content
197
- try:
198
- with open(output_file_path, 'r', encoding='utf-8') as f:
199
- file_content = f.read()
200
- except UnicodeDecodeError:
201
- # If UTF-8 fails, try with different encoding or read as binary for certain formats
202
- try:
203
- with open(output_file_path, 'r', encoding='latin-1') as f:
204
- file_content = f.read()
205
- except:
206
- with open(output_file_path, 'rb') as f:
207
- file_content = f.read().decode('utf-8', errors='replace')
208
 
209
- # Create the markdown link
210
  file_name = Path(output_file_path).name
211
  temp_folder = Path(output_file_path).parent.name
212
  markdown_link = f"[{file_name}](http://your-server:port/gradio_api//file=/tmp/gradio/{temp_folder}/{file_name})"
213
 
214
- # Return JSON with both content and file path
215
  result = {
216
  "content": file_content,
217
  "file_path": markdown_link
 
193
  break
194
 
195
  if output_file_path and os.path.exists(output_file_path):
196
+
197
+ with open(output_file_path, 'r', encoding='utf-8') as f:
198
+ file_content = f.read()
199
+
 
 
 
 
 
 
 
 
200
 
 
201
  file_name = Path(output_file_path).name
202
  temp_folder = Path(output_file_path).parent.name
203
  markdown_link = f"[{file_name}](http://your-server:port/gradio_api//file=/tmp/gradio/{temp_folder}/{file_name})"
204
 
 
205
  result = {
206
  "content": file_content,
207
  "file_path": markdown_link