Dateien nach "app" hochladen

This commit is contained in:
th_ib 2024-01-29 00:47:59 +01:00
parent a59d35fd0e
commit d520cd31c5
2 changed files with 48 additions and 0 deletions

8
app/__init__.py Normal file
View File

@ -0,0 +1,8 @@
from flask import Flask
from flask_htmx import HTMX
app = Flask(__name__)
htmx = HTMX(app)
from app import routes

40
app/routes.py Normal file
View File

@ -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)