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