modified: backend/app.py
modified: frontend/index.html modified: frontend/js/app.js
This commit is contained in:
@@ -59,9 +59,36 @@ app.register_blueprint(finance_blueprint, url_prefix='/api')
|
|||||||
app.register_blueprint(team_blueprint, url_prefix='/api')
|
app.register_blueprint(team_blueprint, url_prefix='/api')
|
||||||
app.register_blueprint(repricer_blueprint, url_prefix='/api')
|
app.register_blueprint(repricer_blueprint, url_prefix='/api')
|
||||||
|
|
||||||
|
# Health check endpoint - проверка состояния приложения и БД
|
||||||
|
from flask import jsonify
|
||||||
|
from .db import get_db_connection, release_db_connection
|
||||||
|
|
||||||
|
@app.route('/api/health')
|
||||||
|
def health_check():
|
||||||
|
db_status = "ok"
|
||||||
|
db_error = None
|
||||||
|
try:
|
||||||
|
conn = get_db_connection()
|
||||||
|
cur = conn.cursor()
|
||||||
|
cur.execute("SELECT 1")
|
||||||
|
release_db_connection(conn)
|
||||||
|
except Exception as e:
|
||||||
|
db_status = "error"
|
||||||
|
db_error = str(e)
|
||||||
|
|
||||||
|
status = "ok" if db_status == "ok" else "degraded"
|
||||||
|
return jsonify({
|
||||||
|
"status": status,
|
||||||
|
"backend": "ok",
|
||||||
|
"database": db_status,
|
||||||
|
"db_error": db_error
|
||||||
|
}), 200 if status == "ok" else 503
|
||||||
|
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
def background_scanner():
|
def background_scanner():
|
||||||
"""Фоновая задача для имитации сканирования маркетплейсов."""
|
"""Фоновая задача для имитации сканирования маркетплейсов."""
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
<form id="auth-form">
|
<form id="auth-form">
|
||||||
<input type="text" id="auth-username" placeholder="Логин" required />
|
<input type="text" id="auth-username" placeholder="Логин" required />
|
||||||
<input type="password" id="auth-password" placeholder="Пароль" required />
|
<input type="password" id="auth-password" placeholder="Пароль" required />
|
||||||
<button type="submit" class="btn-primary" style="width: 100%; margin-top: 1rem;">Войти</button>
|
<button type="submit" id="auth-submit-btn" class="btn-primary" style="width: 100%; margin-top: 1rem;">Войти</button>
|
||||||
</form>
|
</form>
|
||||||
<p style="margin-top: 1rem; text-align: center;">
|
<p style="margin-top: 1rem; text-align: center;">
|
||||||
<a href="#" id="auth-toggle">Нет аккаунта? Зарегистрироваться</a>
|
<a href="#" id="auth-toggle">Нет аккаунта? Зарегистрироваться</a>
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ function initAuth() {
|
|||||||
const authForm = document.getElementById('auth-form');
|
const authForm = document.getElementById('auth-form');
|
||||||
const toggleBtn = document.getElementById('auth-toggle');
|
const toggleBtn = document.getElementById('auth-toggle');
|
||||||
const title = document.getElementById('auth-title');
|
const title = document.getElementById('auth-title');
|
||||||
|
const submitBtn = document.getElementById('auth-submit-btn');
|
||||||
const logoutBtn = document.getElementById('logout-btn');
|
const logoutBtn = document.getElementById('logout-btn');
|
||||||
|
|
||||||
toggleBtn.addEventListener('click', (e) => {
|
toggleBtn.addEventListener('click', (e) => {
|
||||||
@@ -94,6 +95,7 @@ function initAuth() {
|
|||||||
isLoginMode = !isLoginMode;
|
isLoginMode = !isLoginMode;
|
||||||
title.textContent = isLoginMode ? 'Вход в систему' : 'Регистрация';
|
title.textContent = isLoginMode ? 'Вход в систему' : 'Регистрация';
|
||||||
toggleBtn.textContent = isLoginMode ? 'Нет аккаунта? Зарегистрироваться' : 'Уже есть аккаунт? Войти';
|
toggleBtn.textContent = isLoginMode ? 'Нет аккаунта? Зарегистрироваться' : 'Уже есть аккаунт? Войти';
|
||||||
|
submitBtn.textContent = isLoginMode ? 'Войти' : 'Зарегистрироваться';
|
||||||
});
|
});
|
||||||
|
|
||||||
authForm.addEventListener('submit', async (e) => {
|
authForm.addEventListener('submit', async (e) => {
|
||||||
@@ -110,6 +112,7 @@ function initAuth() {
|
|||||||
isLoginMode = true;
|
isLoginMode = true;
|
||||||
title.textContent = 'Вход в систему';
|
title.textContent = 'Вход в систему';
|
||||||
toggleBtn.textContent = 'Нет аккаунта? Зарегистрироваться';
|
toggleBtn.textContent = 'Нет аккаунта? Зарегистрироваться';
|
||||||
|
submitBtn.textContent = 'Войти';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
|||||||
Reference in New Issue
Block a user