Просмотр исходного кода

add eng error message partially

ming 3 лет назад
Родитель
Сommit
800b4852a2
1 измененных файлов с 4 добавлено и 4 удалено
  1. 4 4
      api/main.py

+ 4 - 4
api/main.py

@@ -347,7 +347,7 @@ async def swapFace(req:models.swap_req):
         im = Image.open(requests.get(req.imgurl, stream=True).raw)
         im= im.convert("RGB")
     except:
-        return {'msg':"無法辨別圖片網址"+req.imgurl}
+        return {'msg':{'eng':req.imgurl+'cant be proccessed','zh':"無法辨別圖片網址"+req.imgurl}}
     name_hash = str(time.time()).replace('.','')
     
     x = threading.Thread(target=gen_avatar, args=(name_hash,req.imgurl))
@@ -371,13 +371,13 @@ async def create_upload_file(file: UploadFile = File(...)):
             return {"msg": resource_server+tmp_img_sub_folder+img_name+'.jpg'}
     except Exception as e:
         logging.error(traceback.format_exc())
-        return {'msg':'檔案無法使用'}
+        return {'msg':{'eng':'file cant be prossessed','zh':'檔案無法使用'}}
 
 @app.post("/upload_pttx/")
 async def upload_pttx(file: UploadFile = File(...)):
     try:
         if "_" in file.filename:
-            return {'msg':'檔案無法使用檔名不能含有"_"符號'}
+            return {'msg':{'eng':'symbol"_" is not allowed in file name','zh':'檔案無法使用檔名不能含有"_"符號'}}
         else:
             pttx_name = file.filename+'_'+str(time.time()).replace('.','')
             with open(pttx_dest+pttx_name, "wb+") as file_object:
@@ -385,7 +385,7 @@ async def upload_pttx(file: UploadFile = File(...)):
             return {"msg": resource_server+pttx_sub_folder+pttx_name}
     except Exception as e:
         logging.error(traceback.format_exc())
-        return {'msg':'檔案無法使用'}
+        return {'msg':{'eng':'file cant be prossessed','zh':'檔案無法使用'}}
 
 
 @app.post("/make_anchor_video_gSlide")