imagegpt / app.py
zliang's picture
Upload app.py
e202b48 verified
raw
history blame
733 Bytes
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_LbaYnIi6c/cEKckedLvblvfMEUg=',
private_key='private_jR3Aa0VKd7EpjiTP9KRySHMUqTU=',
url_endpoint='https://ik.imagekit.io/9edzrzk59'
)
@app.get("/")
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=8000)