Makhinur commited on
Commit
4d3127a
·
verified ·
1 Parent(s): 0297c7c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -2
main.py CHANGED
@@ -4,17 +4,19 @@ from gradio_client import Client, handle_file
4
  import shutil
5
  import os
6
  import base64
7
- import os
8
 
9
  app = FastAPI()
 
10
  HF_TOKEN = os.getenv("HF_TOKEN")
11
  # Initialize the Gradio client with the token
12
  client = Client("Makhinur/Bringingoldphotoliveagain", hf_token=HF_TOKEN)
13
 
14
 
15
-
16
  @app.post("/upload/")
17
  async def upload_image(file: UploadFile = File(...)):
 
 
 
18
  # Save the uploaded file to a temporary location
19
  temp_file_path = f"temp_{file.filename}"
20
  with open(temp_file_path, "wb") as buffer:
 
4
  import shutil
5
  import os
6
  import base64
 
7
 
8
  app = FastAPI()
9
+
10
  HF_TOKEN = os.getenv("HF_TOKEN")
11
  # Initialize the Gradio client with the token
12
  client = Client("Makhinur/Bringingoldphotoliveagain", hf_token=HF_TOKEN)
13
 
14
 
 
15
  @app.post("/upload/")
16
  async def upload_image(file: UploadFile = File(...)):
17
+ if not file:
18
+ raise HTTPException(status_code=400, detail="No file uploaded")
19
+
20
  # Save the uploaded file to a temporary location
21
  temp_file_path = f"temp_{file.filename}"
22
  with open(temp_file_path, "wb") as buffer: