ScanOS/backend/app/routers/power.py

14 lines
319 B
Python
Raw Normal View History

2023-09-21 14:56:01 +02:00
from fastapi import APIRouter
import subprocess
router = APIRouter(prefix="/api/power")
@router.post("/shutdown")
async def power_shutdown():
subprocess.call(["sudo", "shutdown", "-h", "now"])
return {}
@router.post("/restart")
async def power_restart():
subprocess.call(["sudo", "reboot"])
return {}