Spaces:
Running
Running
Update api.py
Browse files
api.py
CHANGED
|
@@ -11,8 +11,11 @@ templates = Jinja2Templates(directory="templates")
|
|
| 11 |
|
| 12 |
@app.get('/')
|
| 13 |
async def index(request: Request):
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
@app.post('/remove-bg')
|
|
@@ -35,19 +38,6 @@ async def remove_bg(image: UploadFile = File(...)):
|
|
| 35 |
headers = {"Content-Disposition": "attachment; filename=\"no-bg.png\""}
|
| 36 |
return StreamingResponse(buffer, media_type='image/png', headers=headers)
|
| 37 |
|
| 38 |
-
|
| 39 |
-
@app.get("/ping")
|
| 40 |
-
async def ping():
|
| 41 |
-
"""
|
| 42 |
-
Simple health-check endpoint for uptime monitoring.
|
| 43 |
-
Returns status and current server time.
|
| 44 |
-
"""
|
| 45 |
-
return JSONResponse({
|
| 46 |
-
"status": "ok",
|
| 47 |
-
"message": "Server is alive",
|
| 48 |
-
"timestamp": datetime.datetime.utcnow().isoformat() + "Z"
|
| 49 |
-
})
|
| 50 |
-
|
| 51 |
# If you want to run locally with `python api.py` for quick testing
|
| 52 |
if __name__ == '__main__':
|
| 53 |
import uvicorn
|
|
|
|
| 11 |
|
| 12 |
@app.get('/')
|
| 13 |
async def index(request: Request):
|
| 14 |
+
return JSONResponse({
|
| 15 |
+
"status": "ok",
|
| 16 |
+
"message": "Server is alive",
|
| 17 |
+
"timestamp": datetime.datetime.utcnow().isoformat() + "Z"
|
| 18 |
+
})
|
| 19 |
|
| 20 |
|
| 21 |
@app.post('/remove-bg')
|
|
|
|
| 38 |
headers = {"Content-Disposition": "attachment; filename=\"no-bg.png\""}
|
| 39 |
return StreamingResponse(buffer, media_type='image/png', headers=headers)
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# If you want to run locally with `python api.py` for quick testing
|
| 42 |
if __name__ == '__main__':
|
| 43 |
import uvicorn
|