Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
from fastapi import FastAPI, File, UploadFile
|
| 2 |
-
import
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
logger = logging.getLogger('uvicorn.error')
|
| 5 |
-
logger.setLevel(logging.DEBUG)
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
@app.get("/")
|
|
@@ -14,15 +15,16 @@ def greet_json():
|
|
| 14 |
def make_versions():
|
| 15 |
return("making versions")
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI, File, UploadFile
|
| 2 |
+
import httpx
|
| 3 |
+
from fastapi.responses import JSONResponse
|
| 4 |
+
from io import BytesIO
|
| 5 |
+
|
| 6 |
|
|
|
|
|
|
|
| 7 |
app = FastAPI()
|
| 8 |
|
| 9 |
@app.get("/")
|
|
|
|
| 15 |
def make_versions():
|
| 16 |
return("making versions")
|
| 17 |
|
| 18 |
+
# Replace with your target external API URL
|
| 19 |
+
EXTERNAL_API_URL = "https://external-api.example.com/process"
|
| 20 |
+
|
| 21 |
+
@app.post("/send-image")
|
| 22 |
+
async def send_image(image: UploadFile = File(...)):
|
| 23 |
+
# Read image data
|
| 24 |
+
image_bytes = await image.read()
|
| 25 |
+
|
| 26 |
+
# Optional: prepare image payload for external API
|
| 27 |
+
files = {"file": (image.filename, BytesIO(image_bytes), image.content_type)}
|
| 28 |
+
|
| 29 |
+
# Call external API
|
| 30 |
+
return(f"image uploaded {files}")
|