update
This commit is contained in:
17
app/routers/system.py
Normal file
17
app/routers/system.py
Normal file
@@ -0,0 +1,17 @@
|
||||
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)}
|
||||
Reference in New Issue
Block a user