Moved blueprints to /blueprints/

This commit is contained in:
2026-02-23 13:35:24 +00:00
parent 52db1c3d9b
commit aa1ceb7739
2 changed files with 1 additions and 1 deletions

26
blueprints/static.py Normal file
View File

@ -0,0 +1,26 @@
"""
Holds the blueprint for serving the static folder.
THIS WILL ONLY BE FUNCTIONAL IN DEBUG MODE, as Nginx should serve the static folder in production.
"""
import os
import flask
staticBP = flask.Blueprint('staticPage', __name__, static_folder='./www/')
@staticBP.route('/', defaults={'path': 'index.html'})
@staticBP.route('/<path:path>')
def staticPage(path):
"""
Returns anything requested in the static folder.
"""
if not flask.current_app.debug:
# Return forbidden code if trying to access static files in production mode.
flask.abort(403)
if os.path.isfile(os.path.join(staticBP.static_folder, path, 'index.html')):
path = os.path.join(path, 'index.html')
return flask.send_from_directory(staticBP.static_folder, path)