Spaces:
Running
Running
fix
Browse files- app/main.py +3 -2
app/main.py
CHANGED
@@ -20,6 +20,7 @@ middleware = [
|
|
20 |
|
21 |
app = FastAPI(middleware=middleware)
|
22 |
|
|
|
23 |
session_assistant = ChatPDF()
|
24 |
session_messages = []
|
25 |
|
@@ -37,14 +38,14 @@ def process_input(text: str):
|
|
37 |
def upload(files: list[UploadFile]):
|
38 |
session_assistant.clear()
|
39 |
session_messages = []
|
40 |
-
files_dir = os.path.expanduser("~/wtp_be_files/")
|
41 |
|
42 |
try:
|
43 |
os.makedirs(files_dir)
|
44 |
for file in files:
|
45 |
try:
|
|
|
46 |
file.file.seek(0)
|
47 |
-
with
|
48 |
shutil.copyfileobj(file.file, destination)
|
49 |
finally:
|
50 |
file.file.close()
|
|
|
20 |
|
21 |
app = FastAPI(middleware=middleware)
|
22 |
|
23 |
+
files_dir = os.path.expanduser("~/wtp_be_files/")
|
24 |
session_assistant = ChatPDF()
|
25 |
session_messages = []
|
26 |
|
|
|
38 |
def upload(files: list[UploadFile]):
|
39 |
session_assistant.clear()
|
40 |
session_messages = []
|
|
|
41 |
|
42 |
try:
|
43 |
os.makedirs(files_dir)
|
44 |
for file in files:
|
45 |
try:
|
46 |
+
path = f"{files_dir}/{file.filename}"
|
47 |
file.file.seek(0)
|
48 |
+
with open(path, 'wb') as destination:
|
49 |
shutil.copyfileobj(file.file, destination)
|
50 |
finally:
|
51 |
file.file.close()
|