Инициализация в новом репозитории
This commit is contained in:
commit
eb1f18f53e
374 changed files with 226678 additions and 0 deletions
28
SRV/api/v1/subnet.py
Normal file
28
SRV/api/v1/subnet.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from fastapi import APIRouter, HTTPException
|
||||
from typing import List
|
||||
from models.subnet import SubnetScanResult
|
||||
from models.wifi import WifiScanResult
|
||||
from services.subnet_service import SubnetService
|
||||
from services.wifi_service import WifiService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/scan", response_model=SubnetScanResult)
|
||||
def scan_subnet(subnet: str = "192.168.1.0/24", ports: List[int] = None):
|
||||
"""Сканирует локальную подсеть и возвращает данные об устройствах"""
|
||||
try:
|
||||
subnet_service = SubnetService()
|
||||
result = subnet_service.scan_subnet(subnet, ports)
|
||||
return result
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Ошибка сканирования: {str(e)}")
|
||||
|
||||
@router.get("/wifi", response_model=WifiScanResult)
|
||||
def scan_wifi(timeout: int = 30):
|
||||
"""Сканирует Wi-Fi точки доступа и возвращает данные о них"""
|
||||
try:
|
||||
wifi_service = WifiService()
|
||||
result = wifi_service.scan_wifi(timeout=timeout)
|
||||
return result
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Ошибка сканирования Wi-Fi: {str(e)}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue