Update BrainBot.py
Browse files- BrainBot.py +3 -13
BrainBot.py
CHANGED
@@ -15,27 +15,17 @@ st.markdown(f'<style>{css}</style>', unsafe_allow_html=True)
|
|
15 |
# Function to save the uploaded file as a temporary file and return its path.
|
16 |
def save_uploaded_file(uploaded_file):
|
17 |
file_content = uploaded_file.read() # Load the document
|
18 |
-
st.write("read file")
|
19 |
-
# Create a directory if it doesn't exist
|
20 |
-
data_dir = "/data"
|
21 |
-
# os.makedirs(data_dir, exist_ok=True)
|
22 |
|
23 |
-
# Create a temporary file
|
24 |
-
# with tempfile.NamedTemporaryFile(delete=False, dir=data_dir) as temp_file:
|
25 |
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
26 |
-
st.write("writing file...")
|
27 |
temp_file.write(file_content) # Write the uploaded file content to the temporary file
|
28 |
temp_file_path = temp_file.name # Get the path of the temporary file
|
29 |
return temp_file_path
|
30 |
|
31 |
# Function to save the uploaded image as a temporary file and return its path.
|
32 |
def save_uploaded_image(uploaded_image):
|
33 |
-
# Create a
|
34 |
-
|
35 |
-
# os.makedirs(images_dir, exist_ok=True)
|
36 |
-
|
37 |
-
# Create a temporary file path within the "images" directory with .png extension
|
38 |
-
temp_file_path = os.path.join(images_dir, tempfile.NamedTemporaryFile(suffix=".png").name)
|
39 |
|
40 |
# Write the uploaded image content to the temporary file
|
41 |
with open(temp_file_path, "wb") as temp_file:
|
|
|
15 |
# Function to save the uploaded file as a temporary file and return its path.
|
16 |
def save_uploaded_file(uploaded_file):
|
17 |
file_content = uploaded_file.read() # Load the document
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
# Create a temporary file
|
|
|
20 |
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
|
|
21 |
temp_file.write(file_content) # Write the uploaded file content to the temporary file
|
22 |
temp_file_path = temp_file.name # Get the path of the temporary file
|
23 |
return temp_file_path
|
24 |
|
25 |
# Function to save the uploaded image as a temporary file and return its path.
|
26 |
def save_uploaded_image(uploaded_image):
|
27 |
+
# Create a temporary file path with .png extension
|
28 |
+
temp_file_path = os.path.join(tempfile.NamedTemporaryFile(suffix=".png").name)
|
|
|
|
|
|
|
|
|
29 |
|
30 |
# Write the uploaded image content to the temporary file
|
31 |
with open(temp_file_path, "wb") as temp_file:
|