zliang commited on
Commit
6c2e069
1 Parent(s): 01042b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -43,27 +43,26 @@ def read_root():
43
 
44
 
45
 
 
 
 
 
46
  @app.get("/image_upload")
47
- def upload_image(url,title):
48
  try:
49
-
50
-
51
- # Upload the image to ImageKit
52
-
53
-
54
  options = UploadFileRequestOptions(
55
- overwrite_custom_metadata=True,
56
- custom_metadata={'title': title}
57
  )
58
 
59
  upload = imagekit.upload(
60
- file=url,
61
  file_name="image.jpg",
62
- # options = options
63
  )
64
 
65
  # Return the upload response
66
- return {"message": "uploaded successfuly, check https://aiphotographer.github.io/photographer.html for your work!"}
67
  except Exception as e:
68
  return {"error": str(e)}
69
 
 
43
 
44
 
45
 
46
+ class ImageData(BaseModel):
47
+ url: str
48
+ title: str
49
+
50
  @app.get("/image_upload")
51
+ async def upload_image(data: ImageData):
52
  try:
 
 
 
 
 
53
  options = UploadFileRequestOptions(
54
+ overwrite_custom_metadata=True,
55
+ custom_metadata={'title': data.title}
56
  )
57
 
58
  upload = imagekit.upload(
59
+ file=data.url,
60
  file_name="image.jpg",
61
+ options=options
62
  )
63
 
64
  # Return the upload response
65
+ return {"message": "Uploaded successfully, check https://aiphotographer.github.io/photographer.html for your work!"}
66
  except Exception as e:
67
  return {"error": str(e)}
68