""" 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('/') 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)