byh711 commited on
Commit
152a9ff
·
verified ·
1 Parent(s): 843ce1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -20,10 +20,8 @@ doc_converter = DocumentConverter(
20
  )
21
 
22
  def convert_to_markdown(file):
23
- # Save the uploaded file to a temporary path
24
  input_path = Path(file.name)
25
- with open(input_path, 'wb') as f:
26
- f.write(file.read())
27
 
28
  # Convert the document
29
  result = doc_converter.convert(str(input_path))
@@ -43,14 +41,14 @@ def convert_to_markdown(file):
43
 
44
  return markdown_content
45
 
46
- # Create Gradio interface
47
  iface = gr.Interface(
48
  fn=convert_to_markdown,
49
- inputs=gr.File(label="Upload your document"),
50
  outputs="markdown",
51
  title="Document to Markdown Converter",
52
  description="Upload a document (e.g., PDF, DOCX, PPTX) and get its Markdown version."
53
  )
54
 
55
  if __name__ == "__main__":
56
- iface.launch(share=True)
 
20
  )
21
 
22
  def convert_to_markdown(file):
23
+ # Use the file-like object directly
24
  input_path = Path(file.name)
 
 
25
 
26
  # Convert the document
27
  result = doc_converter.convert(str(input_path))
 
41
 
42
  return markdown_content
43
 
44
+ # Create Gradio interface with type="file"
45
  iface = gr.Interface(
46
  fn=convert_to_markdown,
47
+ inputs=gr.File(label="Upload your document", type="file"),
48
  outputs="markdown",
49
  title="Document to Markdown Converter",
50
  description="Upload a document (e.g., PDF, DOCX, PPTX) and get its Markdown version."
51
  )
52
 
53
  if __name__ == "__main__":
54
+ iface.launch()