Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
7 |
-
if
|
8 |
-
|
9 |
-
|
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()
|