Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -212,11 +212,15 @@ with gr.Blocks() as app:
|
|
212 |
if not file or not db_name or not password:
|
213 |
return "Please provide all required inputs."
|
214 |
|
215 |
-
#
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
|
|
220 |
|
221 |
return create_new_database(file_content, db_name, password)
|
222 |
|
|
|
212 |
if not file or not db_name or not password:
|
213 |
return "Please provide all required inputs."
|
214 |
|
215 |
+
# Check if the file is valid
|
216 |
+
if isinstance(file, str): # Gradio provides the file path as a string
|
217 |
+
try:
|
218 |
+
with open(file, "r", encoding="utf-8") as f:
|
219 |
+
file_content = f.read()
|
220 |
+
except Exception as e:
|
221 |
+
return f"Error reading file: {str(e)}"
|
222 |
+
else:
|
223 |
+
return "Invalid file format. Please upload a .txt file."
|
224 |
|
225 |
return create_new_database(file_content, db_name, password)
|
226 |
|