Update app.py

Rework on 404 error handling
This commit is contained in:
Eric Lay 2024-03-28 11:13:50 -05:00 committed by GitHub
parent 764e8953b0
commit d9b8edbc7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 5 deletions

6
app.py
View File

@ -4,16 +4,12 @@ from flask import Flask, send_from_directory, session, Blueprint, render_templat
app = Flask(__name__) app = Flask(__name__)
app.secret_key = '420-69-LOL' # For using client side session cookies app.secret_key = '420-69-LOL' # For using client side session cookies
# Script must run from root dir containing all websites dirs
# OR change the ROOT_DIR path :)
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
# Point jinja to templates
site = Blueprint('site', __name__, template_folder='Templates')
# Site choosing logic # Site choosing logic
def current_website_dir(): def current_website_dir():
# Script must run from root dir containing all websites dirs # Script must run from root dir containing all websites dirs
# OR change the ROOT_DIR path :) # OR change the ROOT_DIR path :)
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
WEBSITE_DIRS = [name for name in os.listdir(ROOT_DIR) if not name.startswith('.') and os.path.isdir(os.path.join(ROOT_DIR, name))] WEBSITE_DIRS = [name for name in os.listdir(ROOT_DIR) if not name.startswith('.') and os.path.isdir(os.path.join(ROOT_DIR, name))]
session.pop('website_dir', None) # Clear website_dir if exist session.pop('website_dir', None) # Clear website_dir if exist
match session['requests']: #Match Nth page request match session['requests']: #Match Nth page request