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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -6,24 +6,16 @@ def convert_to_markdown(file):
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()
 
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=[
13
+ gr.Textbox(label="Markdown Output", lines=15, interactive=True), # Make the output scrollable
14
+ gr.Button("Copy to Clipboard", type="copy", value="Markdown Output") # Add Copy button
15
  ],
16
  title="File to Markdown Converter",
17
  description="Upload a file to convert its content to Markdown using Microsoft's markitdown library.",
 
18
  )
19
 
20
+ if __name__ == "__main__":
21
+ iface.launch()