35 lines
855 B
Python
35 lines
855 B
Python
from fastapi import APIRouter
|
||
from starlette.requests import Request
|
||
from starlette.responses import HTMLResponse
|
||
from starlette.templating import Jinja2Templates
|
||
from config import TEMPLATES_DIR
|
||
|
||
from scripts.сheck_available_ports import start_check
|
||
|
||
router = APIRouter()
|
||
|
||
templates = Jinja2Templates(directory=TEMPLATES_DIR)
|
||
|
||
|
||
@router.get("", response_class=HTMLResponse)
|
||
async def check_ports(request: Request):
|
||
return templates.TemplateResponse(
|
||
"body-check_ports.html",
|
||
{
|
||
"request": request,
|
||
},
|
||
)
|
||
|
||
|
||
@router.get("/start")
|
||
async def start_check_ports(request: Request, inputText: str):
|
||
|
||
results = start_check(inputText, result_type="test")
|
||
return templates.TemplateResponse(
|
||
"body-check_ports.html",
|
||
{
|
||
"request": request,
|
||
"results": results,
|
||
},
|
||
)
|