Update app.py
Browse files
app.py
CHANGED
@@ -43,27 +43,26 @@ def read_root():
|
|
43 |
|
44 |
|
45 |
|
|
|
|
|
|
|
|
|
46 |
@app.get("/image_upload")
|
47 |
-
def upload_image(
|
48 |
try:
|
49 |
-
|
50 |
-
|
51 |
-
# Upload the image to ImageKit
|
52 |
-
|
53 |
-
|
54 |
options = UploadFileRequestOptions(
|
55 |
-
|
56 |
-
|
57 |
)
|
58 |
|
59 |
upload = imagekit.upload(
|
60 |
-
file=url,
|
61 |
file_name="image.jpg",
|
62 |
-
|
63 |
)
|
64 |
|
65 |
# Return the upload response
|
66 |
-
return {"message": "
|
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 |
|