Move highly-static routes in separate blueprint

This commit is contained in:
Xevion
2022-03-29 23:34:31 -05:00
parent cf8a754caf
commit 6b4d5acfb9
5 changed files with 31 additions and 24 deletions

3
app.py
View File

@@ -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

View File

@@ -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')

23
static_routes.py Normal file
View File

@@ -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')

View File

@@ -3,10 +3,10 @@
created by <a href="https://github.com/Xevion">Ryan Walters</a> and <a href="https://github.com/Seligmann">Zachary Seligman</a>
</p>
<ul class="links">
<li><a href="{{ url_for('main.license') }}">License</a></li>
<li><a href="{{ url_for('main.tos') }}">Terms of Service</a></li>
{# <li><a href="{{ url_for('main.privacy') }}">Privacy</a></li>#}
<li><a href="{{ url_for('main.about') }}">About</a></li>
<li><a href="{{ url_for('static.license') }}">License</a></li>
<li><a href="{{ url_for('static.tos') }}">Terms of Service</a></li>
{# <li><a href="{{ url_for('static.privacy') }}">Privacy</a></li>#}
<li><a href="{{ url_for('static.about') }}">About</a></li>
</ul>
<p class="copyright">
<a href="{{ url_for('main.index') }}">©2022 Runnerspace.live All Rights Reserved.</a>

View File

@@ -24,7 +24,7 @@
{# <li><a href="{{ url_for('main.messages') }}">My Messages</a></li>#}
{# <li><a href="{{ url_for('main.blogs') }}">Blog</a></li>#}
{# <li><a href="{{ url_for('main.groups') }}">Groups</a></li>#}
<li><a href="{{ url_for('main.about') }}">About</a></li>
<li><a href="{{ url_for('static.about') }}">About</a></li>
</ul>
</nav>
</div>