fix: ensure privacy policy read only if path exists
Moved path file opening and reading logic inside a conditional block to prevent attempts to access a file when no valid path is assigned. This avoids potential errors and ensures only existing files are processed.
This commit is contained in:
parent
065738eea2
commit
7682f4ba7f
1 changed files with 8 additions and 9 deletions
|
@ -357,17 +357,16 @@ def init_main_routes(app):
|
|||
elif pathlib.Path("privacy.txt").exists():
|
||||
path = "privacy.txt"
|
||||
|
||||
try:
|
||||
with pathlib.Path(path).open() as f:
|
||||
content = f.read()
|
||||
if path:
|
||||
try:
|
||||
with pathlib.Path(path).open() as f:
|
||||
content = f.read()
|
||||
|
||||
print(path, content)
|
||||
if path.endswith(".md"):
|
||||
content = Markdown().convert(content)
|
||||
|
||||
if path.endswith(".md"):
|
||||
content = Markdown().convert(content)
|
||||
|
||||
except OSError:
|
||||
pass
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
return render_template(
|
||||
"privacypolicy.html", title="Privacy Policy", content=content
|
||||
|
|
Loading…
Reference in a new issue