sblumenf commited on
Commit
ab26203
1 Parent(s): 0a932f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -3,19 +3,16 @@ 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(),
19
  gr.outputs.Textbox()
20
  )
21
  iface.launch()
 
3
  from pdfminer.high_level import extract_text
4
  import urllib.request
5
 
6
+ def read_pdf(file, url):
7
+ if url is not None and url != "":
8
+ file = urllib.request.urlretrieve(url)[0]
9
+ text = extract_text(file)
 
 
 
10
  return text
11
 
12
  iface = gr.Interface(
13
  read_pdf,
14
+ gr.inputs.File(examples='path/to/example_pdf_files'),
15
+ gr.inputs.Textbox(label="Enter URL of pdf"),
16
  gr.outputs.Textbox()
17
  )
18
  iface.launch()