From 7f0dceb6324a327e6e0cc39fedd653201d98fe14 Mon Sep 17 00:00:00 2001 From: Ground-Zerro Date: Tue, 31 Dec 2024 20:01:03 +1100 Subject: [PATCH] up --- web/app.py | 61 ++++++++++---------------------------- web/index.html | 2 +- web/static/для статики JS | 0 web/templates/для шаблонов | 0 4 files changed, 17 insertions(+), 46 deletions(-) create mode 100644 web/static/для статики JS create mode 100644 web/templates/для шаблонов diff --git a/web/app.py b/web/app.py index 3c7f820..18c4cf7 100644 --- a/web/app.py +++ b/web/app.py @@ -1,53 +1,18 @@ -from fastapi import FastAPI, Form, UploadFile +from fastapi import FastAPI, Form, Request from fastapi.responses import FileResponse, HTMLResponse -import asyncio +from fastapi.templating import Jinja2Templates import os app = FastAPI() +# Указываем директории для статических файлов и шаблонов +templates = Jinja2Templates(directory=os.path.dirname(os.path.realpath(__file__))) +app.mount("/static", StaticFiles(directory="static"), name="static") + @app.get("/") -async def get_form(): - html_content = """ - - - - - - DNS Resolver Settings - - -

Настройки

-
-
- Service 1
- Service 2
- Service 3

- -
- DNS Server 1
- DNS Server 2
- DNS Server 3

- -
- Исключить Cloudflare

- -
- До /16 (255.255.0.0)
- До /24 (255.255.255.0)
- Микс /24 и /32
- Не агрегировать

- -
- Windows Route
- Unix Route
- CIDR

- - -
- - - """ - return HTMLResponse(content=html_content) +async def get_form(request: Request): + # Загружаем HTML шаблон (index.html) и передаем в него данные + return templates.TemplateResponse("index.html", {"request": request}) @app.post("/run") async def run_dns_resolver( @@ -55,7 +20,9 @@ async def run_dns_resolver( dns_servers: list[str] = Form(...), cloudflare: str = Form(...), aggregation: str = Form(...), - format: str = Form(...) + format: str = Form(...), + gateway: str = Form(None), + commentary: str = Form(None) ): # Генерация config.ini config_path = "config.ini" @@ -66,6 +33,10 @@ async def run_dns_resolver( config.write(f"cloudflare={cloudflare}\n") config.write(f"subnet={aggregation}\n") config.write(f"filetype={format}\n") + if gateway: + config.write(f"gateway={gateway}\n") + if commentary: + config.write(f"commentary={commentary}\n") # Запуск скрипта result_file = "output.txt" diff --git a/web/index.html b/web/index.html index 7f0614e..facb130 100644 --- a/web/index.html +++ b/web/index.html @@ -185,4 +185,4 @@
Прогресс выполнения будет отображаться здесь...
- + \ No newline at end of file diff --git a/web/static/для статики JS b/web/static/для статики JS new file mode 100644 index 0000000..e69de29 diff --git a/web/templates/для шаблонов b/web/templates/для шаблонов new file mode 100644 index 0000000..e69de29