|
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 = imagekit.upload( |
|
file=url, |
|
file_name="image.jpg", |
|
) |
|
|
|
|
|
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) |
|
|