error pages
This commit is contained in:
26
app.py
26
app.py
@@ -19,9 +19,24 @@ app = Flask(__name__)
|
||||
app.config["SECRET_KEY"] = config.FLASK_CONFIG["secret_key"]
|
||||
app.config["SEND_FILE_MAX_AGE_DEFAULT"] = config.FLASK_CONFIG.get("static_cache_timeout", 60)
|
||||
|
||||
# Bez Eventlet – tryb wątkowy
|
||||
socketio = SocketIO(app, cors_allowed_origins="*", async_mode="threading", logger=False)
|
||||
|
||||
@app.errorhandler(500)
|
||||
def server_error(error):
|
||||
app.logger.error(f'Server error: {str(error)}')
|
||||
return render_template('error.html',
|
||||
status=500,
|
||||
title='Błąd serwera',
|
||||
message='Spróbuj ponownie za chwilę.',
|
||||
footer=config.FOOTER), 500
|
||||
@app.errorhandler(400)
|
||||
@app.errorhandler(404)
|
||||
def client_error(error):
|
||||
return render_template('error.html',
|
||||
status=error.code,
|
||||
title=f'Błąd {error.code}',
|
||||
message='Nieprawidłowe żądanie.',
|
||||
footer=config.FOOTER), error.code
|
||||
|
||||
# --------------------
|
||||
# Helpers
|
||||
@@ -155,9 +170,16 @@ def favicon():
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
safe_phases = {
|
||||
k: {
|
||||
'label': v['label'],
|
||||
'color': v['color']
|
||||
}
|
||||
for k, v in config.PHASES.items()
|
||||
}
|
||||
return render_template(
|
||||
"index.html",
|
||||
phases=config.PHASES,
|
||||
phases=safe_phases,
|
||||
time_ranges=config.TIME_RANGES,
|
||||
default_range=config.DEFAULT_TIME_RANGE,
|
||||
footer=config.FOOTER,
|
||||
|
||||
Reference in New Issue
Block a user