diff options
| -rw-r--r-- | views.py | 19 | 
1 files changed, 11 insertions, 8 deletions
@@ -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,  | 
