sblumenf commited on
Commit
a69dbfc
1 Parent(s): 9366193

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -1,14 +1,21 @@
1
  import gradio as gr
2
  import pdfminer
3
  from pdfminer.high_level import extract_text
 
4
 
5
- def read_pdf(file):
6
- text = extract_text(file.name)
 
 
 
 
 
7
  return text
8
 
9
  iface = gr.Interface(
10
  read_pdf,
11
  gr.inputs.File(),
 
12
  gr.outputs.Textbox()
13
  )
14
  iface.launch()
 
1
  import gradio as gr
2
  import pdfminer
3
  from pdfminer.high_level import extract_text
4
+ import urllib.request
5
 
6
+ def read_pdf(file=None, url=None):
7
+ if file:
8
+ text = extract_text(file.name)
9
+ elif url:
10
+ response = urllib.request.urlopen(url)
11
+ file = response.read()
12
+ text = extract_text(file)
13
  return text
14
 
15
  iface = gr.Interface(
16
  read_pdf,
17
  gr.inputs.File(),
18
+ gr.inputs.Textbox(prompt="Enter a URL that points to a pdf"),
19
  gr.outputs.Textbox()
20
  )
21
  iface.launch()