I have the following code in __init__.py
@app.errorhandler(404) def page_not_found(e): return render_template('404.html'), 404 @app.errorhandler(500) def internal_server_error(e): return render_template('500.html'), 500 @app.errorhandler(403) def page_forbidden(e): return render_template('403.html'), 500
He used to catch all 500 errors and show my beautiful 500.html template. However, I moved all of my views to separate drawing files, and now the 500 error handler does not work. However, this is only a handler. 404 works fine.
If the server generates a 500 error, it will display the Chrome INTERNAL SERVER ERROR error message by default, and not my template. Did I do something wrong when I created all my drawings that could create this problem?
Here is the whole __init__.py file
import datetime import mysql.connector import os from flask import Flask, render_template, session, request, Blueprint from flask.ext.moment import Moment from flask.ext.login import LoginManager from db_classes import User from info import info_blueprint from claims import claims_blueprint from users import users_blueprint from members import members_blueprint from drug import drug_blueprint from auth import auth_blueprint from formulary import formulary_blueprint from config import MYSQL_USR, MYSQL_HOST, MYSQL_PASS, MYSQL_DB, MYSQL_PORT, second_to_live from decorators import role_required app = Flask(__name__, template_folder="static/templates") app.config.from_object('config') moment = Moment(app) login_manager = LoginManager() login_manager.init_app(app) login_manager.session_protection = 'strong' login_manager.login_view = 'login' @login_manager.user_loader def load_user(user_id): return User.query.get(int(user_id))
source share