from fastapi import FastAPI | |
import base64 | |
import os | |
import sys | |
import uvicorn | |
from imagekitio import ImageKit | |
import base64 | |
app = FastAPI() | |
imagekit = ImageKit( | |
public_key=public_key, | |
private_key=private_key, | |
url_endpoint=url_endpoint | |
) | |
def upload_image(url): | |
try: | |
# Upload the image to ImageKit | |
upload = imagekit.upload( | |
file=url, | |
file_name="image.jpg", | |
) | |
# Return the upload response | |
return upload | |
except Exception as e: | |
return {"error": str(e)} | |
if __name__ == "__main__": | |
import uvicorn | |
uvicorn.run(app, host="0.0.0.0", port=7860) | |