Files
werkzeuge/teamleader_test2/network_mapper/main.py
root cb073786b3 Initial commit: Werkzeuge-Sammlung
Enthält:
- rdp_client.py: RDP Client mit GUI und Monitor-Auswahl
- rdp.sh: Bash-basierter RDP Client
- teamleader_test/: Network Scanner Fullstack-App
- teamleader_test2/: Network Mapper CLI

Subdirectories mit eigenem Repo wurden ausgeschlossen.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 09:39:24 +01:00

36 lines
1.0 KiB
Python

"""FastAPI application that exposes the scan API and serves the front-end."""
from __future__ import annotations
import os
from pathlib import Path
from fastapi import FastAPI
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
from network_mapper.scanner import NetworkScanner
BASE_DIR = Path(__file__).resolve().parent.parent
FRONTEND_DIR = BASE_DIR / "frontend"
app = FastAPI(title="LAN Graph Explorer")
scanner = NetworkScanner(
ssh_user=os.environ.get("SSH_USER"),
ssh_key_path=os.environ.get("SSH_KEY_PATH"),
)
app.mount("/static", StaticFiles(directory=FRONTEND_DIR), name="static")
@app.get("/api/scan")
async def api_scan(cidr: str | None = None, concurrency: int = 64, ssh_timeout: float = 5.0):
"""Run a fresh scan and return the topology graph."""
result = await scanner.scan(cidr=cidr, concurrency=concurrency, ssh_timeout=ssh_timeout)
return result.to_dict()
@app.get("/")
async def serve_frontend():
return FileResponse(FRONTEND_DIR / "index.html")