Skip to content

Commit

Permalink
Update to blueprint system
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelCenzano committed Oct 4, 2023
1 parent d5c3823 commit f2a3171
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions labconnect/errors/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
Blueprint for error pages
"""
from flask import Blueprint


error_blueprint = Blueprint("errors", __name__, template_folder="templates")

from . import routes
15 changes: 15 additions & 0 deletions labconnect/errors/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from flask import make_response, render_template, Response

from . import error_blueprint


@error_blueprint.errorhandler(404)
def page_not_found(e) -> Response:
# 404 error page
return make_response(render_template("404.html"), 404)


@error_blueprint.errorhandler(500)
def error_for_server(e) -> Response:
# 500 error page
return make_response(render_template("500.html"), 500)
8 changes: 8 additions & 0 deletions labconnect/main/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Blueprint for main pages
"""
from flask import Blueprint

main_blueprint = Blueprint("main", __name__, template_folder="templates")

from . import routes
9 changes: 9 additions & 0 deletions labconnect/main/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from flask import render_template, Response

from . import main_blueprint


@main_blueprint.route("/")
def index():
# return "Hello World"
return render_template("home.html")

0 comments on commit f2a3171

Please sign in to comment.