Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,7 +58,12 @@ def parse_documents(uploaded_files):
|
|
| 58 |
for file in uploaded_files:
|
| 59 |
try:
|
| 60 |
file_type = file.name.split(".")[-1].lower()
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
# Create a temporary file with the correct extension
|
| 63 |
with tempfile.NamedTemporaryFile(
|
| 64 |
delete=False, suffix=f".{file_type}"
|
|
|
|
| 58 |
for file in uploaded_files:
|
| 59 |
try:
|
| 60 |
file_type = file.name.split(".")[-1].lower()
|
| 61 |
+
|
| 62 |
+
# Handle text files directly
|
| 63 |
+
if file_type == "txt":
|
| 64 |
+
content += file.getvalue().decode("utf-8")
|
| 65 |
+
# Use converter for other supported file types
|
| 66 |
+
elif file_type in ["pdf", "docx", "html"]:
|
| 67 |
# Create a temporary file with the correct extension
|
| 68 |
with tempfile.NamedTemporaryFile(
|
| 69 |
delete=False, suffix=f".{file_type}"
|