From 6b4d5acfb977c87555d2a416591b7571d9f67a48 Mon Sep 17 00:00:00 2001
From: Xevion
Date: Tue, 29 Mar 2022 23:34:31 -0500
Subject: [PATCH] Move highly-static routes in separate blueprint
---
app.py | 3 +++
routes.py | 19 -------------------
static_routes.py | 23 +++++++++++++++++++++++
templates/layouts/footer.html | 8 ++++----
templates/layouts/header.html | 2 +-
5 files changed, 31 insertions(+), 24 deletions(-)
create mode 100644 static_routes.py
diff --git a/app.py b/app.py
index d3dca17..f4416ec 100644
--- a/app.py
+++ b/app.py
@@ -51,6 +51,9 @@ def create_app():
from route_forms import blueprint as forms_blueprint
app.register_blueprint(forms_blueprint)
+ from static_routes import blueprint as static_blueprint
+ app.register_blueprint(static_blueprint)
+
@app.errorhandler(404)
def page_not_found(e):
# note that we set the 404 status explicitly
diff --git a/routes.py b/routes.py
index 852ad88..b66af4d 100644
--- a/routes.py
+++ b/routes.py
@@ -19,11 +19,6 @@ def index(): # put application's code here
return render_template('layouts/index.html', new_users=users, stats=stats)
-@blueprint.route('/about')
-def about():
- return render_template('pages/about.html')
-
-
@blueprint.route('/users')
def browse():
users = User.query.all()
@@ -87,20 +82,6 @@ def edit_user(username: str):
form.process(obj=user)
return render_template('pages/user_edit.html', form=form)
-
-@blueprint.route('/terms_of_service')
-def tos():
- return render_template('static/tos.html')
-
-
-@blueprint.route('/privacy')
-def privacy():
- return render_template('static/privacy.html')
-
-
-@blueprint.route('/license')
-def license():
- return render_template('static/license.html')
# @blueprint.route('/blogs')
# def blogs():
# return render_template('pages/blogs.html')
diff --git a/static_routes.py b/static_routes.py
new file mode 100644
index 0000000..5f00b01
--- /dev/null
+++ b/static_routes.py
@@ -0,0 +1,23 @@
+from flask import Blueprint, redirect, render_template, url_for, request
+
+blueprint = Blueprint('static', __name__)
+
+
+@blueprint.route('/about')
+def about():
+ return render_template('pages/about.html')
+
+
+@blueprint.route('/terms_of_service')
+def tos():
+ return render_template('static/tos.html')
+
+
+@blueprint.route('/privacy')
+def privacy():
+ return render_template('static/privacy.html')
+
+
+@blueprint.route('/license')
+def license():
+ return render_template('static/license.html')
diff --git a/templates/layouts/footer.html b/templates/layouts/footer.html
index c5e100f..e7b3bf9 100644
--- a/templates/layouts/footer.html
+++ b/templates/layouts/footer.html
@@ -3,10 +3,10 @@
created by Ryan Walters and Zachary Seligman
©2022 Runnerspace.live All Rights Reserved.
diff --git a/templates/layouts/header.html b/templates/layouts/header.html
index 1698940..3679961 100644
--- a/templates/layouts/header.html
+++ b/templates/layouts/header.html
@@ -24,7 +24,7 @@
{#
My Messages#}
{# Blog#}
{# Groups#}
- About
+ About