from flask import render_template, redirect, url_for, current_app import os from app import app, htmx def render_htmx_or_full(template_partial, template_full): try: if htmx: return render_template(template_partial) return render_template(template_full) except Exception as e: current_app.logger.error(f"Error rendering template: {e}") # Optionally, you can return a custom error page here return "An error occurred", 500 @app.route('/') def index(): return render_htmx_or_full('partials/index.html', 'index.html') @app.route('/buchhaltung') def buchhaltung(): return render_htmx_or_full('partials/buchhaltung.html', 'index.html') @app.route('/flottenmanagement') def flottenmanagement(): return render_htmx_or_full('partials/flottenmanagement.html', 'index.html') # Additional debug route to check the file structure @app.route('/debug/templates') def debug_templates(): template_dir = os.path.join(current_app.root_path, 'templates') all_files = [] for path, subdirs, files in os.walk(template_dir): for name in files: all_files.append(os.path.join(path, name)) return '\n'.join(all_files)