Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from io import BytesIO
|
3 |
+
from pdfminer.high_level import extract_text
|
4 |
+
import requests
|
5 |
+
|
6 |
+
def read_pdf(file):
|
7 |
+
if isinstance(file, str):
|
8 |
+
if file.startswith('http'):
|
9 |
+
file = BytesIO(requests.get(file).content)
|
10 |
+
text = extract_text(file)
|
11 |
+
return text
|
12 |
+
|
13 |
+
iface = gr.Interface(fn=read_pdf, inputs="file_upload", outputs="text",
|
14 |
+
title="PDF Text Extractor",
|
15 |
+
description="Extract text from a PDF file.")
|
16 |
+
iface.launch()
|