mirror of
https://github.com/Ground-Zerro/DomainMapper.git
synced 2025-12-10 01:47:18 +07:00
up
This commit is contained in:
61
web/app.py
61
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 = """
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>DNS Resolver Settings</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Настройки</h2>
|
||||
<form action="/run" method="post" enctype="multipart/form-data">
|
||||
<label><strong>Список сервисов:</strong></label><br>
|
||||
<input type="checkbox" name="services" value="service1"> Service 1<br>
|
||||
<input type="checkbox" name="services" value="service2"> Service 2<br>
|
||||
<input type="checkbox" name="services" value="service3"> Service 3<br><br>
|
||||
|
||||
<label><strong>Список используемых DNS серверов:</strong></label><br>
|
||||
<input type="checkbox" name="dns_servers" value="dns1"> DNS Server 1<br>
|
||||
<input type="checkbox" name="dns_servers" value="dns2"> DNS Server 2<br>
|
||||
<input type="checkbox" name="dns_servers" value="dns3"> DNS Server 3<br><br>
|
||||
|
||||
<label><strong>Фильтрация Cloudflare:</strong></label><br>
|
||||
<input type="checkbox" name="cloudflare" value="yes"> Исключить Cloudflare<br><br>
|
||||
|
||||
<label><strong>Агрегация подсетей:</strong></label><br>
|
||||
<input type="radio" name="aggregation" value="16"> До /16 (255.255.0.0)<br>
|
||||
<input type="radio" name="aggregation" value="24"> До /24 (255.255.255.0)<br>
|
||||
<input type="radio" name="aggregation" value="mix"> Микс /24 и /32<br>
|
||||
<input type="radio" name="aggregation" value="none" checked> Не агрегировать<br><br>
|
||||
|
||||
<label><strong>Формат сохранения:</strong></label><br>
|
||||
<input type="radio" name="format" value="win"> Windows Route<br>
|
||||
<input type="radio" name="format" value="unix"> Unix Route<br>
|
||||
<input type="radio" name="format" value="cidr" checked> CIDR<br><br>
|
||||
|
||||
<button type="submit">Запустить</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
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"
|
||||
|
||||
@@ -185,4 +185,4 @@
|
||||
|
||||
<div id="progress" style="margin-top: 20px; font-weight: bold;">Прогресс выполнения будет отображаться здесь...</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
0
web/static/для статики JS
Normal file
0
web/static/для статики JS
Normal file
0
web/templates/для шаблонов
Normal file
0
web/templates/для шаблонов
Normal file
Reference in New Issue
Block a user