Skip to content

Commit 92d746a

Browse files
committed
Register errors.py and update it
1 parent c861a50 commit 92d746a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

My_path_team9/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
from flask_login import LoginManager
44
from flask_sqlalchemy import SQLAlchemy
55

6+
67
db = SQLAlchemy()
78
bootstrap = Bootstrap()
89
login_manager = LoginManager()
910

11+
1012
def create_app(config):
1113
app = Flask(__name__)
1214
app.config.from_object(config)
@@ -18,10 +20,12 @@ def create_app(config):
1820
from .main import main_bp
1921
from .student import student_bp
2022
from .teacher import teacher_bp
23+
from .errors import register_error_handlers
2124

2225
app.register_blueprint(auth_bp)
2326
app.register_blueprint(main_bp)
2427
app.register_blueprint(student_bp)
2528
app.register_blueprint(teacher_bp)
29+
register_error_handlers(app)
2630

2731
return app

My_path_team9/errors.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from flask import render_template
2+
3+
def register_error_handlers(app):
4+
@app.errorhandler(404)
5+
def not_found_error(e):
6+
return render_template('page_errors/404.html'), 404
7+
8+
@app.errorhandler(500)
9+
def internal_error(e):
10+
return render_template('page_errors/500.html'), 500

0 commit comments

Comments
 (0)