Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85d758fadb | |||
| 212dd2abcf |
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
NUITKA_BUILD=0
|
NUITKA_BUILD=0
|
||||||
INVENTAR_HTTP_PORT=10000
|
INVENTAR_HTTP_PORT=10000
|
||||||
INVENTAR_HTTP_PORTS=10000
|
INVENTAR_HTTP_PORTS=10000
|
||||||
INVENTAR_APP_IMAGE=ghcr.io/aiirondev/legendary-octo-garbanzo:v0.7.39
|
INVENTAR_APP_IMAGE=ghcr.io/aiirondev/legendary-octo-garbanzo:v0.7.42
|
||||||
INVENTAR_APP_CPUS=1.0
|
INVENTAR_APP_CPUS=1.0
|
||||||
INVENTAR_APP_MEM_LIMIT=384m
|
INVENTAR_APP_MEM_LIMIT=384m
|
||||||
INVENTAR_APP_MEM_SWAP_LIMIT=768m
|
INVENTAR_APP_MEM_SWAP_LIMIT=768m
|
||||||
|
|||||||
+22
-1
@@ -25,9 +25,10 @@ Features:
|
|||||||
- Booking and reservation of items
|
- Booking and reservation of items
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from flask import Flask, render_template, request, redirect, url_for, session, flash, send_from_directory, get_flashed_messages, jsonify, Response, make_response, send_file
|
from flask import Flask, render_template, request, redirect, url_for, session, flash, send_from_directory, get_flashed_messages, jsonify, Response, make_response, send_file, abort
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
|
from jinja2 import TemplateNotFound
|
||||||
import user as us
|
import user as us
|
||||||
import items as it
|
import items as it
|
||||||
import ausleihung as au
|
import ausleihung as au
|
||||||
@@ -412,6 +413,26 @@ def _set_security_headers(response):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
@app.errorhandler(TemplateNotFound)
|
||||||
|
def handle_template_not_found(e):
|
||||||
|
"""Handle missing template files with a 404 response."""
|
||||||
|
app.logger.error(f"Template not found: {e.name}")
|
||||||
|
if request.is_json or request.path.startswith('/api/'):
|
||||||
|
return jsonify({'error': 'Template not found', 'status': 404}), 404
|
||||||
|
return abort(404)
|
||||||
|
|
||||||
|
|
||||||
|
@app.errorhandler(404)
|
||||||
|
def handle_not_found(e):
|
||||||
|
"""Handle 404 errors with a user-friendly response."""
|
||||||
|
app.logger.warning(f"404 Not Found: {request.path}")
|
||||||
|
if request.is_json or request.path.startswith('/api/'):
|
||||||
|
return jsonify({'error': 'Not found', 'status': 404}), 404
|
||||||
|
if 'username' in session:
|
||||||
|
return render_template('error.html', error_code=404, error_message='Seite nicht gefunden.'), 404
|
||||||
|
return redirect(url_for('login'))
|
||||||
|
|
||||||
|
|
||||||
def _csrf_error_response(message='CSRF token fehlt oder ist ungültig.'):
|
def _csrf_error_response(message='CSRF token fehlt oder ist ungültig.'):
|
||||||
if request.is_json or request.path.startswith('/api/') or request.path in {'/download_book_cover', '/proxy_image', '/log_mobile_issue'}:
|
if request.is_json or request.path.startswith('/api/') or request.path in {'/download_book_cover', '/proxy_image', '/log_mobile_issue'}:
|
||||||
return jsonify({'error': message}), 400
|
return jsonify({'error': message}), 400
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% if error_code == 404 %}
|
||||||
|
Seite nicht gefunden - Inventarsystem
|
||||||
|
{% else %}
|
||||||
|
Fehler - Inventarsystem
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="error-container" style="text-align: center; padding: 60px 20px; min-height: 70vh; display: flex; flex-direction: column; justify-content: center; align-items: center;">
|
||||||
|
<div style="max-width: 600px;">
|
||||||
|
<!-- Error Code Display -->
|
||||||
|
<div style="font-size: 120px; font-weight: bold; color: #ef4444; margin-bottom: 20px;">
|
||||||
|
{{ error_code }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Error Title -->
|
||||||
|
<h1 style="font-size: 32px; margin: 20px 0; color: #1f2937;">
|
||||||
|
{% if error_code == 404 %}
|
||||||
|
Seite nicht gefunden
|
||||||
|
{% else %}
|
||||||
|
Ein Fehler ist aufgetreten
|
||||||
|
{% endif %}
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<!-- Error Message -->
|
||||||
|
<p style="font-size: 18px; color: #6b7280; margin: 20px 0 40px;">
|
||||||
|
{{ error_message or 'Es tut uns leid, aber die angeforderte Seite konnte nicht gefunden werden.' }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div style="display: flex; gap: 15px; justify-content: center; flex-wrap: wrap;">
|
||||||
|
<a href="{{ url_for('home') }}" class="button" style="background-color: #3b82f6; color: white; padding: 12px 30px; text-decoration: none; border-radius: 5px; display: inline-block; font-weight: 500;">
|
||||||
|
Zur Startseite
|
||||||
|
</a>
|
||||||
|
<a href="javascript:history.back()" class="button" style="background-color: #6b7280; color: white; padding: 12px 30px; text-decoration: none; border-radius: 5px; display: inline-block; font-weight: 500;">
|
||||||
|
Zurück
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Additional Help -->
|
||||||
|
<div style="margin-top: 60px; padding: 20px; background-color: #f3f4f6; border-radius: 8px;">
|
||||||
|
<p style="color: #6b7280; font-size: 14px;">
|
||||||
|
Wenn Sie denken, dass dies ein Fehler ist, oder Sie Hilfe benötigen,
|
||||||
|
<a href="{{ url_for('impressum') }}" style="color: #3b82f6; text-decoration: none;">kontaktieren Sie den Administrator</a>.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.error-container {
|
||||||
|
animation: fadeIn 0.3s ease-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(10px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
transform: translateY(-2px);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user