fix
This commit is contained in:
parent
f85a010efa
commit
d1bc1fdf18
|
@ -1,10 +0,0 @@
|
|||
from api.swagger import router as swagger_router
|
||||
from fastapi import APIRouter
|
||||
|
||||
from config import settings
|
||||
|
||||
router = APIRouter()
|
||||
router.include_router(
|
||||
swagger_router,
|
||||
prefix=settings.prefix.swagger,
|
||||
)
|
2
main.py
2
main.py
|
@ -5,7 +5,7 @@ import uvicorn
|
|||
from fastapi import FastAPI
|
||||
from fastapi.responses import ORJSONResponse
|
||||
from starlette.staticfiles import StaticFiles
|
||||
from web.router import router as web_router
|
||||
from web.routers import router as web_router
|
||||
|
||||
|
||||
input_text = """
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
from fastapi import APIRouter
|
||||
from web.router import router as web_router
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
router.include_router(
|
||||
web_router,
|
||||
prefix="",
|
||||
)
|
|
@ -1,61 +0,0 @@
|
|||
from fastapi import APIRouter, Form
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import HTMLResponse
|
||||
from starlette.templating import Jinja2Templates
|
||||
from fastapi.openapi.docs import get_swagger_ui_html
|
||||
|
||||
from config import settings
|
||||
from config import TEMPLATES_DIR
|
||||
|
||||
from scripts.сheck_available_ports import start_check
|
||||
|
||||
router = APIRouter(
|
||||
tags=["Web"],
|
||||
)
|
||||
|
||||
templates = Jinja2Templates(directory=TEMPLATES_DIR)
|
||||
|
||||
|
||||
@router.get("/web/check_ports", response_class=HTMLResponse)
|
||||
async def check_ports(request: Request):
|
||||
return templates.TemplateResponse(
|
||||
"body-check_ports.html",
|
||||
{
|
||||
"request": request,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/web/start_check_ports")
|
||||
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,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/docs", include_in_schema=False)
|
||||
async def custom_swagger_ui_html():
|
||||
return get_swagger_ui_html(
|
||||
openapi_url=settings.swagger.openapi_url,
|
||||
title=settings.swagger.title,
|
||||
oauth2_redirect_url=settings.swagger.oauth2_redirect_url,
|
||||
swagger_js_url=settings.swagger.swagger_js_url,
|
||||
swagger_css_url=settings.swagger.swagger_css_url,
|
||||
swagger_favicon_url=settings.swagger.swagger_favicon_url,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/", response_class=HTMLResponse)
|
||||
async def start_page(request: Request):
|
||||
return templates.TemplateResponse(
|
||||
"base.html",
|
||||
{
|
||||
"request": request,
|
||||
},
|
||||
)
|
|
@ -0,0 +1,22 @@
|
|||
from fastapi import APIRouter
|
||||
|
||||
from web.routers.swagger import router as swagger_router
|
||||
from web.routers.check_ports import router as check_ports_router
|
||||
from web.routers.start_page import router as start_page_router
|
||||
|
||||
|
||||
router = APIRouter(
|
||||
tags=["Web"],
|
||||
)
|
||||
router.include_router(
|
||||
swagger_router,
|
||||
prefix="/docs",
|
||||
)
|
||||
router.include_router(
|
||||
check_ports_router,
|
||||
prefix="/web/check_ports",
|
||||
)
|
||||
router.include_router(
|
||||
start_page_router,
|
||||
prefix="",
|
||||
)
|
|
@ -0,0 +1,34 @@
|
|||
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,
|
||||
},
|
||||
)
|
|
@ -0,0 +1,19 @@
|
|||
from fastapi import APIRouter
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import HTMLResponse
|
||||
from starlette.templating import Jinja2Templates
|
||||
from config import TEMPLATES_DIR
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
templates = Jinja2Templates(directory=TEMPLATES_DIR)
|
||||
|
||||
|
||||
@router.get("/", response_class=HTMLResponse)
|
||||
async def start_page(request: Request):
|
||||
return templates.TemplateResponse(
|
||||
"base.html",
|
||||
{
|
||||
"request": request,
|
||||
},
|
||||
)
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
<input type="text" id="inputText" name="inputText" placeholder="Введите значение" />
|
||||
<button hx-get="/web/start_check_ports" hx-include="#inputText" hx-target='#body'>Проверить</button>
|
||||
<button hx-get="/web/check_ports/start" hx-include="#inputText" hx-target='#body'>Проверить</button>
|
||||
|
||||
|
||||
<div id="result">
|
||||
|
|
Loading…
Reference in New Issue