han-byeol commited on
Commit
42e8d6e
ยท
1 Parent(s): 2470c40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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
- for doc in docs:
34
- if doc.type == 'text/plain':
35
- text = doc.getvalue().decode("utf-8")
36
- text_data += text if text else "" # ํŒŒ์ผ์ด ๋น„์–ด์žˆ์ง€ ์•Š์€ ๊ฒฝ์šฐ๋งŒ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
 
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