From 51e4d7a4f63b6baaa5bc45cfbd47c48a8893bc1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 23 Jul 2026 10:23:22 +0400 Subject: [PATCH] Fix: add app.py for gunicorn, error handling in route --- app.py | 4 ++++ app/routes/main.py | 17 +++++++++++------ app/templates/index.html | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 app.py diff --git a/app.py b/app.py new file mode 100644 index 0000000..bc73234 --- /dev/null +++ b/app.py @@ -0,0 +1,4 @@ +"""Точка входа для gunicorn — app:app.""" +from app import create_app + +app = create_app() diff --git a/app/routes/main.py b/app/routes/main.py index ea1859d..d2fe989 100644 --- a/app/routes/main.py +++ b/app/routes/main.py @@ -10,9 +10,14 @@ bp = Blueprint("main", __name__) @bp.route("/") def index(): - client = HttpClient( - current_app.config["NUBES_API_ENDPOINT"], - current_app.config["NUBES_API_TOKEN"], - ) - org = get_organization(client) - return render_template("index.html", organization=org) + 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/app/templates/index.html b/app/templates/index.html index a0b490f..f570db2 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -35,7 +35,7 @@ {% else %}
-

Организация не найдена. Проверьте токен и стенд.

+

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

{% endif %}