Update app.py
Browse files
app.py
CHANGED
|
@@ -30,10 +30,11 @@ def get_pdf_text(pdf_docs):
|
|
| 30 |
# txt ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 31 |
def get_text_file(docs):
|
| 32 |
text_data = ""
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 37 |
return text_data
|
| 38 |
|
| 39 |
|
|
|
|
| 30 |
# txt ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 31 |
def get_text_file(docs):
|
| 32 |
text_data = ""
|
| 33 |
+
if docs and hasattr(docs, '__iter__'): # docs๊ฐ None์ด ์๋๊ณ iterableํ์ง ํ์ธํฉ๋๋ค.
|
| 34 |
+
for doc in docs:
|
| 35 |
+
if doc.type == 'text/plain':
|
| 36 |
+
text = doc.getvalue().decode("utf-8")
|
| 37 |
+
text_data += text if text else "" # ํ์ผ์ด ๋น์ด์์ง ์์ ๊ฒฝ์ฐ๋ง ์ถ๊ฐํฉ๋๋ค.
|
| 38 |
return text_data
|
| 39 |
|
| 40 |
|