Initial commit

This commit is contained in:
Oliver Traber 2023-09-21 14:56:01 +02:00
commit b9d5c06956
Signed by: Bluemedia
GPG key ID: C0674B105057136C
55 changed files with 4706 additions and 0 deletions

View file

View file

@ -0,0 +1,14 @@
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 {}

View file

@ -0,0 +1,23 @@
from typing import Annotated
from app.scanner.scanner import Scanner
from app.main import get_scanner
from fastapi import APIRouter, Depends
from app.data import schemas, models
router = APIRouter(prefix="/api/scan")
@router.post("")
async def scan(scanner: Annotated[Scanner, Depends(get_scanner)]):
scanner.scan()
return []
@router.get("/status", response_model=schemas.ScanStatus)
async def status(scanner: Annotated[Scanner, Depends(get_scanner)]):
pages = [schemas.ScanPage.from_orm(page) for page in scanner.get_pages()]
return schemas.ScanStatus(pages=pages,status=scanner.get_status())
@router.get("/debug")
async def debug(scanner: Annotated[Scanner, Depends(get_scanner)]):
return scanner.get_options()