AlirezaF138 commited on
Commit
d6bc506
·
verified ·
1 Parent(s): 441778d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -6,13 +6,24 @@ def convert_to_markdown(file):
6
  result = markitdown.convert(file.name)
7
  return result.text_content
8
 
 
9
  iface = gr.Interface(
10
  fn=convert_to_markdown,
11
  inputs=gr.File(label="Upload your file"),
12
- outputs=gr.Textbox(label="Markdown Output"),
 
 
 
13
  title="File to Markdown Converter",
14
  description="Upload a file to convert its content to Markdown using Microsoft's markitdown library.",
 
15
  )
16
 
17
- if __name__ == "__main__":
18
- iface.launch()
 
 
 
 
 
 
 
6
  result = markitdown.convert(file.name)
7
  return result.text_content
8
 
9
+ # Create Gradio interface
10
  iface = gr.Interface(
11
  fn=convert_to_markdown,
12
  inputs=gr.File(label="Upload your file"),
13
+ outputs=[
14
+ gr.Textbox(label="Markdown Output", lines=20, interactive=False, show_label=False),
15
+ gr.Button("Copy to Clipboard") # Button to copy the text to clipboard
16
+ ],
17
  title="File to Markdown Converter",
18
  description="Upload a file to convert its content to Markdown using Microsoft's markitdown library.",
19
+ layout="vertical"
20
  )
21
 
22
+ # Adding functionality to copy the text to clipboard
23
+ def copy_to_clipboard(text):
24
+ return text # This is handled automatically by Gradio
25
+
26
+ # Bind copy button to copy functionality
27
+ iface.load(fn=None, inputs=None, outputs=None, api_name="copy")
28
+
29
+ iface.launch()