Update main.py
Browse files
main.py
CHANGED
@@ -87,13 +87,13 @@ async def get_data(input_file: UploadFile = File(...)):
|
|
87 |
text = ""
|
88 |
|
89 |
if file_type == "application/pdf":
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
else:
|
98 |
raise HTTPException(status_code=400, detail="Unsupported file type")
|
99 |
|
|
|
87 |
text = ""
|
88 |
|
89 |
if file_type == "application/pdf":
|
90 |
+
# Read PDF file using PyPDF2
|
91 |
+
pdf_reader = PdfReader(io.BytesIO(file_content))
|
92 |
+
for page in pdf_reader.pages:
|
93 |
+
text += page.extract_text()
|
94 |
+
|
95 |
+
if text=="":
|
96 |
+
text = vision(file_content)
|
97 |
else:
|
98 |
raise HTTPException(status_code=400, detail="Unsupported file type")
|
99 |
|