Spaces:
Running
Running
Update main.py
Browse files- app/main.py +6 -5
app/main.py
CHANGED
@@ -54,17 +54,18 @@ async def process_input(text: str):
|
|
54 |
return StreamingResponse(astreamer(generator), media_type='text/event-stream')
|
55 |
|
56 |
async def parse_body(request: Request):
|
57 |
-
data
|
58 |
return data
|
59 |
|
60 |
@app.post("/upload")
|
61 |
-
def upload(
|
62 |
-
|
63 |
-
if data:
|
64 |
try:
|
|
|
|
|
65 |
path = f"{files_dir}/{filename}"
|
66 |
with open(path, "wb") as f:
|
67 |
-
f.write(data)
|
68 |
session_assistant.ingest(files_dir)
|
69 |
pathlib.Path(path).unlink()
|
70 |
except Exception as e:
|
|
|
54 |
return StreamingResponse(astreamer(generator), media_type='text/event-stream')
|
55 |
|
56 |
async def parse_body(request: Request):
|
57 |
+
data = await request.body()
|
58 |
return data
|
59 |
|
60 |
@app.post("/upload")
|
61 |
+
def upload(data = Depends(parse_body)):
|
62 |
+
if data.get('bytes', None) and data.get('filename', None):
|
|
|
63 |
try:
|
64 |
+
filename = data['filename']
|
65 |
+
print("Filename: " + filename)
|
66 |
path = f"{files_dir}/{filename}"
|
67 |
with open(path, "wb") as f:
|
68 |
+
f.write(data['bytes'])
|
69 |
session_assistant.ingest(files_dir)
|
70 |
pathlib.Path(path).unlink()
|
71 |
except Exception as e:
|