Refactoring - Fix1
Dieser Commit ist enthalten in:
@@ -44,15 +44,21 @@ scheduler.start()
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
# Import and register blueprints
|
||||
from routes.auth_routes import auth_bp
|
||||
from routes.admin_routes import admin_bp
|
||||
from routes.api_routes import api_bp
|
||||
from routes.batch_routes import batch_bp
|
||||
from routes.customer_routes import customer_bp
|
||||
from routes.export_routes import export_bp
|
||||
from routes.license_routes import license_bp
|
||||
from routes.resource_routes import resource_bp
|
||||
from routes.session_routes import session_bp
|
||||
try:
|
||||
from routes.auth_routes import auth_bp
|
||||
from routes.admin_routes import admin_bp
|
||||
from routes.api_routes import api_bp
|
||||
from routes.batch_routes import batch_bp
|
||||
from routes.customer_routes import customer_bp
|
||||
from routes.export_routes import export_bp
|
||||
from routes.license_routes import license_bp
|
||||
from routes.resource_routes import resource_bp
|
||||
from routes.session_routes import session_bp
|
||||
print("All blueprints imported successfully!")
|
||||
except Exception as e:
|
||||
print(f"Blueprint import error: {str(e)}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
# Register all blueprints
|
||||
app.register_blueprint(auth_bp)
|
||||
@@ -66,6 +72,27 @@ app.register_blueprint(resource_bp)
|
||||
app.register_blueprint(session_bp)
|
||||
|
||||
|
||||
# Debug routes to test
|
||||
@app.route('/test-customers-licenses')
|
||||
def test_route():
|
||||
return "Test route works! If you see this, routing is working."
|
||||
|
||||
@app.route('/direct-customers-licenses')
|
||||
def direct_customers_licenses():
|
||||
"""Direct route without blueprint"""
|
||||
try:
|
||||
return render_template("customers_licenses.html", customers=[])
|
||||
except Exception as e:
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
@app.route('/debug-routes')
|
||||
def debug_routes():
|
||||
"""Show all registered routes"""
|
||||
routes = []
|
||||
for rule in app.url_map.iter_rules():
|
||||
routes.append(f"{rule.endpoint}: {rule.rule}")
|
||||
return "<br>".join(sorted(routes))
|
||||
|
||||
# Scheduled Backup Job
|
||||
def scheduled_backup():
|
||||
"""Erstellt ein automatisches Backup"""
|
||||
@@ -91,13 +118,21 @@ scheduler.add_job(
|
||||
# Error handlers
|
||||
@app.errorhandler(404)
|
||||
def not_found(e):
|
||||
return render_template('404.html'), 404
|
||||
try:
|
||||
return render_template('404.html'), 404
|
||||
except:
|
||||
return "404 - Page not found", 404
|
||||
|
||||
|
||||
@app.errorhandler(500)
|
||||
def server_error(e):
|
||||
logging.error(f"Server error: {str(e)}")
|
||||
return render_template('500.html'), 500
|
||||
import traceback
|
||||
error_msg = f"Server error: {str(e)}\n{traceback.format_exc()}"
|
||||
logging.error(error_msg)
|
||||
try:
|
||||
return render_template('500.html'), 500
|
||||
except:
|
||||
return f"500 - Internal Server Error\n\n{error_msg}", 500
|
||||
|
||||
|
||||
# Context processors
|
||||
@@ -112,5 +147,32 @@ def inject_global_vars():
|
||||
}
|
||||
|
||||
|
||||
# Simple test route that should always work
|
||||
@app.route('/simple-test')
|
||||
def simple_test():
|
||||
return "Simple test works!"
|
||||
|
||||
@app.route('/test-db')
|
||||
def test_db():
|
||||
"""Test database connection"""
|
||||
try:
|
||||
import psycopg2
|
||||
conn = psycopg2.connect(
|
||||
host=os.getenv("POSTGRES_HOST", "postgres"),
|
||||
port=os.getenv("POSTGRES_PORT", "5432"),
|
||||
dbname=os.getenv("POSTGRES_DB"),
|
||||
user=os.getenv("POSTGRES_USER"),
|
||||
password=os.getenv("POSTGRES_PASSWORD")
|
||||
)
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT COUNT(*) FROM customers")
|
||||
count = cur.fetchone()[0]
|
||||
cur.close()
|
||||
conn.close()
|
||||
return f"Database works! Customers count: {count}"
|
||||
except Exception as e:
|
||||
import traceback
|
||||
return f"Database error: {str(e)}<br><pre>{traceback.format_exc()}</pre>"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000)
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren