From dfa71380913c836d3e926899a09d069eed081660 Mon Sep 17 00:00:00 2001 From: thematdev Date: Mon, 4 Apr 2022 23:14:14 +0300 Subject: [PATCH] Fix non-working code --- app/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index aecd424..f3f8acb 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -29,7 +29,8 @@ def render_page(page): path = f'{PANDOC_PATH}/{page}' whitelist = WHITELIST_PATH with open(whitelist, 'r') as f: - if page not in f.readlines(): + lines = f.read().splitlines() + if page not in lines: raise Exception("Page doesn't exist!") if not os.path.exists(f'{path}'): raise Exception("Page doesn't exist!") @@ -45,7 +46,9 @@ def get_pandoc_page(page): path = f'{PANDOC_PATH}/{page}' whitelist = WHITELIST_PATH with open(whitelist, 'r') as f: - if page not in f.readlines(): + lines = f.read().splitlines() + if page not in lines: + print('Access to page not in list {page}') return 'This page does not exist' if not os.path.exists(f'{path}'): # TODO: Add 404 handler