From 6cb8c05f05b5c8977ab96e416650149a6ffa2916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 23 Jul 2026 11:10:33 +0400 Subject: [PATCH] Strip to minimal: single route, static HTML, no logic --- site/api/__init__.py | 0 site/api/http_client.py | 27 --------------- site/app.py | 18 ++++------ site/operations/__init__.py | 0 site/operations/get_instances.py | 18 ---------- site/routes/__init__.py | 0 site/routes/main.py | 23 ------------- site/templates/base.html | 20 ------------ site/templates/index.html | 56 ++++++++------------------------ 9 files changed, 21 insertions(+), 141 deletions(-) delete mode 100644 site/api/__init__.py delete mode 100644 site/api/http_client.py delete mode 100644 site/operations/__init__.py delete mode 100644 site/operations/get_instances.py delete mode 100644 site/routes/__init__.py delete mode 100644 site/routes/main.py delete mode 100644 site/templates/base.html diff --git a/site/api/__init__.py b/site/api/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/site/api/http_client.py b/site/api/http_client.py deleted file mode 100644 index 3196054..0000000 --- a/site/api/http_client.py +++ /dev/null @@ -1,27 +0,0 @@ -"""HTTP-клиент Nubes API — только Bearer + User-Agent.""" - -import requests - - -class HttpClient: - """Минимальная обёртка над requests для API облака.""" - - def __init__(self, endpoint: str, token: str): - self._endpoint = endpoint.rstrip("/") - self._session = requests.Session() - self._session.headers.update({ - "Authorization": f"Bearer {token}", - "User-Agent": "Mozilla/5.0", - }) - - def get(self, path: str, **kwargs) -> dict: - kwargs.setdefault("timeout", 10) - r = self._session.get(f"{self._endpoint}{path}", **kwargs) - r.raise_for_status() - return r.json() - - def post(self, path: str, data: dict, **kwargs) -> dict: - kwargs.setdefault("timeout", 30) - r = self._session.post(f"{self._endpoint}{path}", json=data, **kwargs) - r.raise_for_status() - return r.json() diff --git a/site/app.py b/site/app.py index f16d5de..fac5750 100644 --- a/site/app.py +++ b/site/app.py @@ -1,18 +1,14 @@ -"""Точка входа — запускается как python site/app.py.""" +"""Точка входа — минимальное приложение.""" import os import sys -# site/ не может быть пакетом (конфликт с stdlib site.py) sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) -from flask import Flask - -from routes.main import bp as main_bp - -NUBES_API_ENDPOINT = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc") -NUBES_API_TOKEN = os.getenv("NUBES_API_TOKEN", "") +from flask import Flask, render_template app = Flask(__name__) -app.config["NUBES_API_ENDPOINT"] = NUBES_API_ENDPOINT -app.config["NUBES_API_TOKEN"] = NUBES_API_TOKEN -app.register_blueprint(main_bp) + + +@app.route("/") +def index(): + return render_template("index.html") diff --git a/site/operations/__init__.py b/site/operations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/site/operations/get_instances.py b/site/operations/get_instances.py deleted file mode 100644 index f099b75..0000000 --- a/site/operations/get_instances.py +++ /dev/null @@ -1,18 +0,0 @@ -"""GET /instances — получить список инстансов пользователя.""" - -from api.http_client import HttpClient - - -def get_instances(client: HttpClient) -> list[dict]: - """Возвращает все инстансы текущего пользователя.""" - data = client.get("/instances", params={"pageSize": 200}) - return data.get("results", []) - - -def get_organization(client: HttpClient) -> dict | None: - """Найти организацию среди инстансов (svcId=19).""" - instances = get_instances(client) - for inst in instances: - if inst.get("serviceId") == 19: - return inst - return None diff --git a/site/routes/__init__.py b/site/routes/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/site/routes/main.py b/site/routes/main.py deleted file mode 100644 index c81522b..0000000 --- a/site/routes/main.py +++ /dev/null @@ -1,23 +0,0 @@ -"""Главная страница — blueprint.""" - -from flask import Blueprint, current_app, render_template - -from api.http_client import HttpClient -from operations.get_instances import get_organization - -bp = Blueprint("main", __name__) - - -@bp.route("/") -def index(): - org = None - error = None - try: - client = HttpClient( - current_app.config["NUBES_API_ENDPOINT"], - current_app.config["NUBES_API_TOKEN"], - ) - org = get_organization(client) - except Exception as e: - error = str(e) - return render_template("index.html", organization=org, error=error) diff --git a/site/templates/base.html b/site/templates/base.html deleted file mode 100644 index 82edcbb..0000000 --- a/site/templates/base.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - {% block title %}Autotest Nubes{% endblock %} - - - - {% block head %}{% endblock %} - - -
-
- {% block content %}{% endblock %} -
-
- - - diff --git a/site/templates/index.html b/site/templates/index.html index f570db2..ee65470 100644 --- a/site/templates/index.html +++ b/site/templates/index.html @@ -1,44 +1,16 @@ -{% extends "base.html" %} -{% block title %}Autotest Nubes{% endblock %} -{% block content %} - -
-
- - Организация -
-
- {% if organization %} - - - - - - - - - - - - - - - - - -
ИмяinstanceUidСервисСтатус
{{ organization.displayName }}{{ organization.instanceUid }}{{ organization.svc }} - - - {{ organization.state.explainedStatus or "OK" }} - -
- {% else %} -
- -

{% if error %}Ошибка: {{ error }}{% else %}Организация не найдена.{% endif %}

+ + + + + Autotest + + + +
+
Autotest
+
+

OK

- {% endif %}
-
- -{% endblock %} + +