mitulagr2 commited on
Commit
06dc580
1 Parent(s): 31c1d58

Update main.py

Browse files
Files changed (1) hide show
  1. 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: bytes = await request.body()
58
  return data
59
 
60
  @app.post("/upload")
61
- def upload(filename: str, data: bytes = Depends(parse_body)):
62
- print("Filename: " + filename)
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: