attempt to load resolved journal files
one step closer to actual functionality, attempt to load the resolved markdown file in the instance directory, or 404 if it doesn't exist
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
"""Journal functionality."""
|
||||
from flask import Blueprint
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, abort, current_app as app
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
bp = Blueprint('journal', __name__, url_prefix='/')
|
||||
|
||||
@@ -7,7 +11,19 @@ bp = Blueprint('journal', __name__, url_prefix='/')
|
||||
@bp.route('/', defaults={'path': 'index'})
|
||||
@bp.route('/<path:path>')
|
||||
def display_journal_entry(path):
|
||||
return path
|
||||
"""Get the file contents of the requested path and render the file."""
|
||||
resolved_path = journal_file_resolver(path)
|
||||
logger.info("received request for path '%s', resolved to '%s'", path, resolved_path)
|
||||
try:
|
||||
with app.open_instance_resource(resolved_path, 'r') as entry_file:
|
||||
logger.debug("file '%s' found", resolved_path)
|
||||
except FileNotFoundError:
|
||||
logger.warning("requested path '%s' (resolved path '%s') not found!", path, resolved_path)
|
||||
abort(404)
|
||||
else:
|
||||
return "OK"
|
||||
|
||||
return resolved_path
|
||||
|
||||
|
||||
def journal_file_resolver(path):
|
||||
|
||||
Reference in New Issue
Block a user