rogerxavier commited on
Commit
679ffd8
1 Parent(s): da78506

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +9 -7
api.py CHANGED
@@ -32,14 +32,16 @@ def t5():
32
 
33
 
34
  ##这个比较快不用异步
35
- @app.post("/getOriginalMangaList")
36
- async def getOriginalMangaList(images: List[UploadFile] = File(...)):
 
37
  for idx, image in enumerate(images):
38
- img = await image.read()
39
- image = Image.open(io.BytesIO(img)).convert("L").convert("RGB")
40
- path_to_image = f"/manga/{idx}.jpg"
41
- image.save(path_to_image)
42
- return "获取图片保存成功"
 
43
  ##这个比较快不用异步
44
 
45
  ##这个比较快不用异步
 
32
 
33
 
34
  ##这个比较快不用异步
35
+ @app.post("/getOriginalMangaList") #增加指定保存路径功能,默认是/manga路径
36
+ def getOriginalMangaList(images: List[UploadFile] = File(...), save_path: str = "/manga"):
37
+ saved_files = []
38
  for idx, image in enumerate(images):
39
+ img = image.file.read()
40
+ image_data = Image.open(io.BytesIO(img)).convert("L").convert("RGB")
41
+ path_to_image = os.path.join(save_path, f"{idx}.jpg")
42
+ image_data.save(path_to_image)
43
+ saved_files.append(path_to_image)
44
+ return {"message": "Images saved successfully", "saved_files": saved_files}
45
  ##这个比较快不用异步
46
 
47
  ##这个比较快不用异步