aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormjfernez <mjf@mjfer.net>2022-02-03 00:38:22 -0500
committermjfernez <mjf@mjfer.net>2022-02-03 00:38:22 -0500
commit3ccea676191e24add12f68011726ed6ea80f5ee1 (patch)
treed5c599cae0d882cada1d7fccd96b29b088403896
parent283654d9a0d644ec3cd6e9c06898f11ac8effa78 (diff)
downloadezcms-3ccea676191e24add12f68011726ed6ea80f5ee1.tar.gz
Fix 500 internal error (merge from mjfer.net)
-rw-r--r--views.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/views.py b/views.py
index 4a41248..3393cb2 100644
--- a/views.py
+++ b/views.py
@@ -3,7 +3,7 @@ views.py - defines the logic that generates views that a user sees when
browsing to certain pages
"""
import os
-from flask import request, send_from_directory, abort
+from flask import send_from_directory, abort
from flask import render_template, render_template_string, make_response
from siteconfig import siteconfig
from server import app, cache
@@ -49,16 +49,17 @@ def render_file(path):
"""
if is_hidden_path(path):
abort(404)
+
abs_path = siteconfig.BASE_DIR + path
context = default_context()
- context.update(
- {
- 'title': path.split('.')[0].upper(),
- 'parent_dir': '/' + '/'.join(path.split('/')[:-1]),
- 'last_update': file_last_modified(abs_path),
- }
- )
if os.path.isfile(abs_path):
+ context.update(
+ {
+ 'title': path.split('.')[0].upper(),
+ 'parent_dir': '/' + '/'.join(path.split('/')[:-1]),
+ 'last_update': file_last_modified(abs_path)
+ }
+ )
if abs_path.endswith('.html'):
with open(abs_path, 'rb') as f:
content = f.read().decode("UTF-8")
@@ -81,6 +82,8 @@ def render_file(path):
dirs, files, links, description = index_dir(abs_path)
context.update(
{
+ 'title': path.split('.')[0].upper(),
+ 'parent_dir': '/' + '/'.join(path.split('/')[:-1]),
'cur_path': path,
'cur_dir': path.split('/')[-1] + '/',
'dirs': dirs,