DDingcheol commited on
Commit
4e51127
Β·
1 Parent(s): bd29c3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -28,12 +28,15 @@ def get_pdf_text(pdf_docs):
28
  def get_text_file(docs):
29
  text_list = []
30
  for file in docs:
31
- if file.type == 'text/plain':
 
 
 
32
  # 파일이 .txt인 경우
33
  text = file.getvalue().decode("utf-8") # 파일 λ‚΄μš©μ„ utf-8 ν˜•μ‹μœΌλ‘œ λ””μ½”λ”©ν•˜μ—¬ ν…μŠ€νŠΈλ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
34
  text_list.append(text)
35
  else:
36
- print(f"Unsupported file type: {file.type}. Skipping processing.")
37
 
38
  return text_list
39
 
 
28
  def get_text_file(docs):
29
  text_list = []
30
  for file in docs:
31
+ filename = file.name
32
+ file_extension = filename.split(".")[-1] # 파일 μ΄λ¦„μ—μ„œ ν™•μž₯자 μΆ”μΆœ
33
+
34
+ if file_extension.lower() == 'txt':
35
  # 파일이 .txt인 경우
36
  text = file.getvalue().decode("utf-8") # 파일 λ‚΄μš©μ„ utf-8 ν˜•μ‹μœΌλ‘œ λ””μ½”λ”©ν•˜μ—¬ ν…μŠ€νŠΈλ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
37
  text_list.append(text)
38
  else:
39
+ print(f"Unsupported file type: {file_extension}. Skipping processing.")
40
 
41
  return text_list
42