Update app.py
Browse files
app.py
CHANGED
@@ -105,16 +105,12 @@ def _parse_text(text):
|
|
105 |
text = "".join(lines)
|
106 |
return text
|
107 |
|
108 |
-
def save_image(image_file,
|
109 |
-
upload_dir =
|
110 |
-
upload_dir.mkdir(parents=True, exist_ok=True)
|
111 |
filename = secrets.token_hex(10) + Path(image_file.name).suffix
|
112 |
-
file_path = upload_dir / filename
|
113 |
with open(file_path, "wb") as f:
|
114 |
-
|
115 |
-
f.write(image_file.value.encode())
|
116 |
-
else:
|
117 |
-
f.write(image_file.read())
|
118 |
return str(file_path)
|
119 |
|
120 |
def add_file(history, task_history, file):
|
|
|
105 |
text = "".join(lines)
|
106 |
return text
|
107 |
|
108 |
+
def save_image(image_file, upload_dir):
|
109 |
+
Path(upload_dir).mkdir(parents=True, exist_ok=True)
|
|
|
110 |
filename = secrets.token_hex(10) + Path(image_file.name).suffix
|
111 |
+
file_path = Path(upload_dir) / filename
|
112 |
with open(file_path, "wb") as f:
|
113 |
+
f.write(image_file.read())
|
|
|
|
|
|
|
114 |
return str(file_path)
|
115 |
|
116 |
def add_file(history, task_history, file):
|