Update app.py

- moving escape template choosing logic into the website_dir function to better grab assets 
- changed formatting on string for selecting escape template
This commit is contained in:
Eric Lay 2024-03-27 10:02:20 -05:00 committed by GitHub
parent ee1403de23
commit 574c66db5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 9 deletions

12
app.py
View File

@ -13,11 +13,17 @@ unique_requests = set()
# OR change the ROOT_DIR path below :)
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))]
print(ROOT_DIR)
# Site choosing logic
website_dir = None
def current_website_dir():
global request_count
request_count += 1
if request_count % 5 == 0:
global website_dir
website_dir = str(ROOT_DIR+"/Marvel")
else:
website_dir = random.choice(WEBSITE_DIRS)
# Make static files available
@ -29,12 +35,6 @@ def static_proxy(filename):
@app.route('/', methods=['GET'])
def index():
current_website_dir()
global request_count
request_count += 1
if request_count % 5 == 0:
return send_from_directory(str(ROOT_DIR+"Marvel/"), 'index.html')
else:
return send_from_directory(website_dir, 'index.html')
if __name__ == "__main__":