Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -106,9 +106,11 @@ def read_pdf_online(url):
|
|
| 106 |
print(f"reading {url}")
|
| 107 |
response = requests.get(url, stream=True)
|
| 108 |
text=""
|
|
|
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
|
|
|
| 112 |
with open(f"test.pdf", "wb") as f:
|
| 113 |
f.write(response.content)
|
| 114 |
#f.close()
|
|
@@ -121,13 +123,16 @@ def read_pdf_online(url):
|
|
| 121 |
text = f'{text}\n{page.extract_text()}'
|
| 122 |
print(f"PDF_TEXT:: {text}")
|
| 123 |
return text
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
VERBOSE = True
|
| 133 |
MAX_HISTORY = 100
|
|
|
|
| 106 |
print(f"reading {url}")
|
| 107 |
response = requests.get(url, stream=True)
|
| 108 |
text=""
|
| 109 |
+
#################
|
| 110 |
|
| 111 |
+
#####################
|
| 112 |
+
try:
|
| 113 |
+
if response.status_code == 200:
|
| 114 |
with open(f"test.pdf", "wb") as f:
|
| 115 |
f.write(response.content)
|
| 116 |
#f.close()
|
|
|
|
| 123 |
text = f'{text}\n{page.extract_text()}'
|
| 124 |
print(f"PDF_TEXT:: {text}")
|
| 125 |
return text
|
| 126 |
+
else:
|
| 127 |
+
text = response.status_code
|
| 128 |
+
print(text)
|
| 129 |
+
return text
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
except Exception as e:
|
| 133 |
+
print (e)
|
| 134 |
+
return e
|
| 135 |
+
|
| 136 |
|
| 137 |
VERBOSE = True
|
| 138 |
MAX_HISTORY = 100
|