Ashrafb commited on
Commit
215cdaf
1 Parent(s): bff39e2

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -1
main.py CHANGED
@@ -16,6 +16,8 @@ client = Client("https://ashrafb-image-to-sketch.hf.space/", hf_token=hf_token)
16
 
17
  import tempfile
18
 
 
 
19
  import base64
20
 
21
  @app.post("/upload/")
@@ -39,8 +41,11 @@ async def upload_file(file: UploadFile = File(...)):
39
  }
40
  else:
41
  return {"error": "Invalid result from the prediction API."}
 
 
42
  finally:
43
- os.unlink(temp_file_path)
 
44
 
45
 
46
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
 
16
 
17
  import tempfile
18
 
19
+
20
+
21
  import base64
22
 
23
  @app.post("/upload/")
 
41
  }
42
  else:
43
  return {"error": "Invalid result from the prediction API."}
44
+ except Exception as e:
45
+ return {"error": str(e)}
46
  finally:
47
+ if os.path.exists(temp_file_path):
48
+ os.unlink(temp_file_path)
49
 
50
 
51
  app.mount("/", StaticFiles(directory="static", html=True), name="static")