mirror of
https://github.com/BluemediaDev/ScanOS.git
synced 2025-05-08 11:11:35 +02:00
Initial commit
This commit is contained in:
commit
b9d5c06956
55 changed files with 4706 additions and 0 deletions
0
backend/app/routers/__init__.py
Normal file
0
backend/app/routers/__init__.py
Normal file
14
backend/app/routers/power.py
Normal file
14
backend/app/routers/power.py
Normal 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 {}
|
23
backend/app/routers/scan.py
Normal file
23
backend/app/routers/scan.py
Normal 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()
|
Loading…
Add table
Add a link
Reference in a new issue