2025-12-01 02:22:43 +00:00
|
|
|
import httpx
|
2025-11-06 07:23:24 +00:00
|
|
|
from fastapi import APIRouter
|
|
|
|
|
from datetime import datetime, timedelta
|
2025-12-01 02:22:43 +00:00
|
|
|
from core.config import API_VERSION, GEOSERVER_URL
|
2025-11-06 07:23:24 +00:00
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
@router.get("/status")
|
|
|
|
|
async def server_status():
|
|
|
|
|
utc_time = datetime.utcnow()
|
|
|
|
|
wib_time = utc_time + timedelta(hours=7)
|
|
|
|
|
formatted_time = wib_time.strftime("%d-%m-%Y %H:%M:%S")
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
"status": "success",
|
|
|
|
|
"message": "Server is running smoothly ✅",
|
|
|
|
|
"data": {
|
|
|
|
|
"service": "upload_automation",
|
|
|
|
|
"timestamp": f"{formatted_time} WIB"
|
|
|
|
|
},
|
|
|
|
|
"meta": {"version": API_VERSION, "environment": "deployment"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-12-01 02:22:43 +00:00
|
|
|
@router.get("/status/geoserver")
|
|
|
|
|
async def check_geoserver_auth():
|
|
|
|
|
url = f"{GEOSERVER_URL}/geoserver/rest/about/version."
|
|
|
|
|
auth = ("admin", "geoserver")
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
async with httpx.AsyncClient() as client:
|
|
|
|
|
response = await client.get(url, auth=auth, timeout=5)
|
|
|
|
|
return {
|
|
|
|
|
"status": "OK" if response.status_code == 200 else "ERROR",
|
|
|
|
|
"code": response.status_code,
|
|
|
|
|
"response": response.text
|
|
|
|
|
}
|
|
|
|
|
except Exception as e:
|
|
|
|
|
return {"status": "FAILED", "error": str(e)}
|
2025-11-06 07:23:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|