This repository has been archived on 2026-02-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
breakpilot-pwa/backend/system_api.py
BreakPilot Dev 19855efacc
Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
feat: BreakPilot PWA - Full codebase (clean push without large binaries)
All services: admin-v2, studio-v2, website, ai-compliance-sdk,
consent-service, klausur-service, voice-service, and infrastructure.
Large PDFs and compiled binaries excluded via .gitignore.
2026-02-11 13:25:58 +01:00

67 lines
1.7 KiB
Python

"""
System API endpoints for health checks and system information.
Provides:
- /health - Basic health check
- /api/v1/system/local-ip - Local network IP for QR-code mobile upload
"""
import os
import socket
from fastapi import APIRouter
router = APIRouter(tags=["System"])
@router.get("/health")
async def health_check():
"""
Basic health check endpoint.
Returns healthy status and service name.
"""
return {
"status": "healthy",
"service": "breakpilot-backend"
}
@router.get("/api/v1/system/local-ip")
async def get_local_ip():
"""
Return the local network IP address.
Used for QR-code generation for mobile PDF upload.
Mobile devices can't reach localhost, so we need the actual network IP.
Priority:
1. LOCAL_NETWORK_IP environment variable (explicit configuration)
2. Auto-detection via socket connection
3. Fallback to default 192.168.178.157
"""
# Check environment variable first
env_ip = os.getenv("LOCAL_NETWORK_IP")
if env_ip:
return {"ip": env_ip}
# Try to auto-detect
try:
# Create a socket to an external address to determine local IP
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(0.1)
# Connect to a public DNS server (doesn't actually send anything)
s.connect(("8.8.8.8", 80))
local_ip = s.getsockname()[0]
s.close()
# Validate it's a private IP
if (local_ip.startswith("192.168.") or
local_ip.startswith("10.") or
(local_ip.startswith("172.") and 16 <= int(local_ip.split('.')[1]) <= 31)):
return {"ip": local_ip}
except Exception:
pass
# Fallback to default
return {"ip": "192.168.178.157"}