diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..9df6689 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,8 @@ +from flask import Flask +from flask_htmx import HTMX + +app = Flask(__name__) + +htmx = HTMX(app) + +from app import routes diff --git a/app/routes.py b/app/routes.py new file mode 100644 index 0000000..19683e8 --- /dev/null +++ b/app/routes.py @@ -0,0 +1,40 @@ +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)