Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
| 4 |
|
| 5 |
def scrape(instring):
|
| 6 |
html_src=(f'''
|
|
@@ -10,7 +10,23 @@ def scrape(instring):
|
|
| 10 |
</div>''')
|
| 11 |
return gr.HTML.update(f'''{html_src}''')
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
with gr.Blocks() as app:
|
| 16 |
gr.Markdown('''<h1>PDF Viewer''')
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
from pdfreader import PdfReader
|
| 4 |
|
| 5 |
def scrape(instring):
|
| 6 |
html_src=(f'''
|
|
|
|
| 10 |
</div>''')
|
| 11 |
return gr.HTML.update(f'''{html_src}''')
|
| 12 |
|
| 13 |
+
def scrape00(instring):
|
| 14 |
+
response = requests.get(instring, stream=True)
|
| 15 |
+
|
| 16 |
+
if response.status_code == 200:
|
| 17 |
+
with open("data.pdf", "wb") as f:
|
| 18 |
+
f.write(response.content)
|
| 19 |
+
else:
|
| 20 |
+
print(response.status_code)
|
| 21 |
+
|
| 22 |
|
| 23 |
+
out = Path("./data.pdf")
|
| 24 |
+
print (out)
|
| 25 |
+
reader = PdfReader("data.pdf")
|
| 26 |
+
number_of_pages = len(reader.pages)
|
| 27 |
+
page = reader.pages[0]
|
| 28 |
+
text = page.extract_text()
|
| 29 |
+
return gr.HTML.update(f'''<embed src={out} type="application/pdf" width="100%" height="500px" />''')
|
| 30 |
|
| 31 |
with gr.Blocks() as app:
|
| 32 |
gr.Markdown('''<h1>PDF Viewer''')
|