Fix: add app.py for gunicorn, error handling in route
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
"""Точка входа для gunicorn — app:app."""
|
||||||
|
from app import create_app
|
||||||
|
|
||||||
|
app = create_app()
|
||||||
+11
-6
@@ -10,9 +10,14 @@ bp = Blueprint("main", __name__)
|
|||||||
|
|
||||||
@bp.route("/")
|
@bp.route("/")
|
||||||
def index():
|
def index():
|
||||||
client = HttpClient(
|
org = None
|
||||||
current_app.config["NUBES_API_ENDPOINT"],
|
error = None
|
||||||
current_app.config["NUBES_API_TOKEN"],
|
try:
|
||||||
)
|
client = HttpClient(
|
||||||
org = get_organization(client)
|
current_app.config["NUBES_API_ENDPOINT"],
|
||||||
return render_template("index.html", organization=org)
|
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)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<div class="empty">
|
<div class="empty">
|
||||||
<i data-lucide="alert-circle" style="width: 24px; height: 24px; color: var(--muted);"></i>
|
<i data-lucide="alert-circle" style="width: 24px; height: 24px; color: var(--muted);"></i>
|
||||||
<p>Организация не найдена. Проверьте токен и стенд.</p>
|
<p>{% if error %}Ошибка: {{ error }}{% else %}Организация не найдена.{% endif %}</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user