18 lines
453 B
Python
18 lines
453 B
Python
from fastapi import APIRouter
|
|
import requests
|
|
|
|
router = APIRouter(
|
|
prefix="/system",
|
|
tags=["system"],
|
|
responses={404: {"description": "Not found"}},
|
|
)
|
|
|
|
@router.get("/ip")
|
|
async def get_public_ip():
|
|
try:
|
|
response = requests.get("https://api.ipify.org?format=json", timeout=5)
|
|
response.raise_for_status()
|
|
return response.json()
|
|
except Exception as e:
|
|
return {"ip": "Error fetching IP", "error": str(e)}
|