Fix regression on 404 redirects

This commit is contained in:
massimilianodelliubaldini
2025-08-02 22:50:59 -04:00
committed by black-sliver
parent d408f7cabc
commit 84c2d70d9a

View File

@@ -87,19 +87,22 @@ def start_playing():
@cache.cached() @cache.cached()
def game_info(game, lang): def game_info(game, lang):
"""Game Info Pages""" """Game Info Pages"""
theme = get_world_theme(game) try:
secure_game_name = secure_filename(game) theme = get_world_theme(game)
lang = secure_filename(lang) secure_game_name = secure_filename(game)
document = render_markdown(os.path.join( lang = secure_filename(lang)
app.static_folder, "generated", "docs", document = render_markdown(os.path.join(
secure_game_name, f"{lang}_{secure_game_name}.md" app.static_folder, "generated", "docs",
)) secure_game_name, f"{lang}_{secure_game_name}.md"
return render_template( ))
"markdown_document.html", return render_template(
title=f"{game} Guide", "markdown_document.html",
html_from_markdown=document, title=f"{game} Guide",
theme=theme, html_from_markdown=document,
) theme=theme,
)
except FileNotFoundError:
return abort(404)
@app.route('/games') @app.route('/games')
@@ -112,19 +115,22 @@ def games():
@app.route('/tutorial/<string:game>/<string:file>') @app.route('/tutorial/<string:game>/<string:file>')
@cache.cached() @cache.cached()
def tutorial(game: str, file: str): def tutorial(game: str, file: str):
theme = get_world_theme(game) try:
secure_game_name = secure_filename(game) theme = get_world_theme(game)
file = secure_filename(file) secure_game_name = secure_filename(game)
document = render_markdown(os.path.join( file = secure_filename(file)
app.static_folder, "generated", "docs", document = render_markdown(os.path.join(
secure_game_name, file+".md" app.static_folder, "generated", "docs",
)) secure_game_name, file+".md"
return render_template( ))
"markdown_document.html", return render_template(
title=f"{game} Guide", "markdown_document.html",
html_from_markdown=document, title=f"{game} Guide",
theme=theme, html_from_markdown=document,
) theme=theme,
)
except FileNotFoundError:
return abort(404)
@app.route('/tutorial/') @app.route('/tutorial/')