Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
# This source code is licensed under the license found in the
|
2 |
-
# LICENSE file in the root directory of this source tree.
|
3 |
|
4 |
from argparse import ArgumentParser
|
5 |
from pathlib import Path
|
@@ -104,19 +102,12 @@ def _parse_text(text):
|
|
104 |
text = "".join(lines)
|
105 |
return text
|
106 |
def save_image(image_file):
|
107 |
-
# Create a directory for uploaded images if it doesn't exist
|
108 |
upload_dir = Path(uploaded_file_dir) / "uploads"
|
109 |
upload_dir.mkdir(parents=True, exist_ok=True)
|
110 |
-
|
111 |
-
# Generate a unique filename for the image
|
112 |
filename = secrets.token_hex(10) + Path(image_file.name).suffix
|
113 |
-
|
114 |
-
# Save the image to the filesystem
|
115 |
file_path = upload_dir / filename
|
116 |
with open(file_path, "wb") as f:
|
117 |
f.write(image_file.read())
|
118 |
-
|
119 |
-
# Return the path to the saved image
|
120 |
return str(file_path)
|
121 |
|
122 |
def add_file(history, task_history, file):
|
|
|
|
|
|
|
1 |
|
2 |
from argparse import ArgumentParser
|
3 |
from pathlib import Path
|
|
|
102 |
text = "".join(lines)
|
103 |
return text
|
104 |
def save_image(image_file):
|
|
|
105 |
upload_dir = Path(uploaded_file_dir) / "uploads"
|
106 |
upload_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
107 |
filename = secrets.token_hex(10) + Path(image_file.name).suffix
|
|
|
|
|
108 |
file_path = upload_dir / filename
|
109 |
with open(file_path, "wb") as f:
|
110 |
f.write(image_file.read())
|
|
|
|
|
111 |
return str(file_path)
|
112 |
|
113 |
def add_file(history, task_history, file):
|