more updates
All checks were successful
Build and push container image / build-and-push-image (push) Successful in 2m59s

This commit is contained in:
2025-08-06 22:39:06 +01:00
parent df59a2c097
commit a0562330a3
23 changed files with 94 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
# Imports
from flask import Blueprint, render_template, request, abort, send_from_directory
from flask import Blueprint, render_template, request, abort, send_from_directory, send_file
from os import getenv as env
import logging
@@ -23,22 +23,31 @@ def index():
return render_template('index.html')
# Route for robots.txt, sitemap.xml, and favicon.ico
@bp.route('/robots.txt')
@bp.route('/sitemap.xml')
# Route for favicon
@bp.route('/favicon.ico')
def web_stuffs():
return send_from_directory(
env('STATIC_FOLDER', default='../static'),
request.path.lstrip('/')
)
def favicon():
return send_file('../static/content/other/favicon.ico')
# catch-all route for any other static pages (only in root path)
@bp.route('/<string:filename>')
def static_files(filename):
# Route for robots.txt
@bp.route('/robots.txt')
def robots():
return send_file('../static/content/other/robots.txt')
# Route for sitemap.xml
@bp.route('/sitemap.xml')
def sitemap():
return send_file('../static/content/other/sitemap.xml')
# Catch-all route for generic pages
@bp.route('/<path:filename>')
def catch_all(filename):
# try to find template in the pages directory and add .html extension
if not filename.endswith('.html'):
filename += '.html'
try:
return render_template(filename if filename.endswith('.html') else filename + '.html')
return render_template(f'pages/{filename}')
except Exception as e:
log.error(f"Error serving static file {filename}: {e}")
abort(404)
abort(404, f"Template '{filename}' not found: {e}")