50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
from fastapi import APIRouter, Form
|
|
from starlette.requests import Request
|
|
from starlette.responses import HTMLResponse
|
|
from starlette.templating import Jinja2Templates
|
|
from config import TEMPLATES_DIR
|
|
|
|
from scripts import check_available_ports
|
|
|
|
router = APIRouter()
|
|
|
|
templates = Jinja2Templates(directory=TEMPLATES_DIR)
|
|
|
|
|
|
@router.get("", response_class=HTMLResponse)
|
|
async def mikrotik_conf(request: Request):
|
|
return templates.TemplateResponse(
|
|
"mikrotik_conf/body-mikrotik_conf.html",
|
|
{
|
|
"request": request,
|
|
},
|
|
)
|
|
|
|
|
|
@router.get("/get-ports", response_class=HTMLResponse)
|
|
async def mikrotik_conf_generate(request: Request, model: str):
|
|
if model == "rb5009ug":
|
|
return templates.TemplateResponse(
|
|
"mikrotik_conf/ports_rb5009ug.html",
|
|
{
|
|
"request": request,
|
|
},
|
|
)
|
|
|
|
|
|
@router.get("/generate")
|
|
async def mikrotik_conf_generate(request: Request, inputText: str):
|
|
|
|
return templates.TemplateResponse(
|
|
"mikrotik_conf/body-mikrotik_conf.html",
|
|
{
|
|
"request": request,
|
|
},
|
|
)
|
|
|
|
|
|
@router.post("/process-text")
|
|
async def test(inputText: str = Form(...)):
|
|
processed_text = inputText.upper()
|
|
return processed_text
|