rewrite
This commit is contained in:
14
app.py
14
app.py
@@ -12,15 +12,15 @@ from flask import Flask, render_template, redirect, url_for, session
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
from config.settings import *
|
||||
from database import db, migrate, init_db
|
||||
from database import db, migrate # ✅ NIE importuj init_db tutaj!
|
||||
from routes.main_routes import main_bp
|
||||
from routes.edit_routes import edit_bp
|
||||
from routes.auth_routes import auth_bp
|
||||
from routes.user_routes import user_bp
|
||||
from auth.auth_middleware import setup_auth, login_required
|
||||
from utils.stats_utils import fetch_haproxy_stats, parse_haproxy_stats
|
||||
from routes.vhost_routes import vhost_bp
|
||||
from routes.cert_routes import cert_bp
|
||||
from auth.auth_middleware import setup_auth, login_required
|
||||
from utils.stats_utils import fetch_haproxy_stats, parse_haproxy_stats
|
||||
|
||||
|
||||
# ===== BASE DIRECTORY =====
|
||||
@@ -60,7 +60,7 @@ app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
|
||||
print("[APP] Initializing database...", flush=True)
|
||||
db.init_app(app)
|
||||
migrate.init_app(app, db)
|
||||
init_db(app)
|
||||
# ❌ USUŃ TĘ LINIĘ: init_db(app)
|
||||
print("[APP] Database initialized", flush=True)
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(user_bp)
|
||||
app.register_blueprint(vhost_bp)
|
||||
app.register_blueprint(cert_bp)
|
||||
|
||||
print("[APP] Blueprints registered", flush=True)
|
||||
|
||||
|
||||
@@ -253,6 +252,11 @@ if __name__ == '__main__':
|
||||
print(f"[APP] Environment: {'Development' if DEBUG else 'Production'}", flush=True)
|
||||
print(f"[APP] Running on: https://[::]:5000 (IPv6)", flush=True)
|
||||
|
||||
# Initialize database before running
|
||||
with app.app_context():
|
||||
from database import init_db
|
||||
init_db(app)
|
||||
|
||||
app.run(
|
||||
host='::',
|
||||
port=5000,
|
||||
|
||||
Reference in New Issue
Block a user