Spaces:
Running
Running
Update api.py
Browse files
api.py
CHANGED
|
@@ -59,6 +59,13 @@ def get_text_column(df):
|
|
| 59 |
return col
|
| 60 |
return None
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# POST /predict
|
| 64 |
@app.post("/predict")
|
|
@@ -125,17 +132,3 @@ async def download(file: str):
|
|
| 125 |
if not file or not os.path.exists(file):
|
| 126 |
raise HTTPException(status_code=404, detail="File not found")
|
| 127 |
return FileResponse(file, filename=os.path.basename(file))
|
| 128 |
-
|
| 129 |
-
@app.get("/")
|
| 130 |
-
async def ping():
|
| 131 |
-
"""
|
| 132 |
-
Simple health-check endpoint for uptime monitoring.
|
| 133 |
-
Returns status and current server time.
|
| 134 |
-
"""
|
| 135 |
-
return JSONResponse({
|
| 136 |
-
"status": "ok",
|
| 137 |
-
"message": "Server is alive",
|
| 138 |
-
"timestamp": datetime.datetime.utcnow().isoformat() + "Z"
|
| 139 |
-
})
|
| 140 |
-
|
| 141 |
-
# Run with: uvicorn main:app --host 0.0.0.0 --port 7860
|
|
|
|
| 59 |
return col
|
| 60 |
return None
|
| 61 |
|
| 62 |
+
@app.api_route("/", methods=["GET", "HEAD"])
|
| 63 |
+
async def index(request: Request):
|
| 64 |
+
return JSONResponse({
|
| 65 |
+
"status": "ok",
|
| 66 |
+
"message": "Server is alive",
|
| 67 |
+
"timestamp": datetime.datetime.utcnow().isoformat() + "Z"
|
| 68 |
+
})
|
| 69 |
|
| 70 |
# POST /predict
|
| 71 |
@app.post("/predict")
|
|
|
|
| 132 |
if not file or not os.path.exists(file):
|
| 133 |
raise HTTPException(status_code=404, detail="File not found")
|
| 134 |
return FileResponse(file, filename=os.path.basename(file))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|