Handle unexistence of page

This commit is contained in:
thematdev 2023-01-27 17:39:13 +03:00
parent 85073b161e
commit 1eba074b6a

View File

@ -24,8 +24,6 @@ def get_all_names():
def get_page(name: str) -> WikiPage:
if name not in get_all_names():
raise Exception("Page doesn't exist!")
path = f'{PANDOC_PATH}/{name}'
with open(f'{path}/config.json', 'r') as f:
page = WikiPage.parse_raw(f.read())
@ -47,6 +45,8 @@ def dated_url_for(endpoint, **values):
@app.route(f'/{PANDOC_LINK}/<name>')
def get_pandoc_page(name: str):
if name not in get_all_names():
return "Page doesn't exist"
page = get_page(name)
template = page.template
with open(page.get_file('render.html'), 'r') as f: