From 1409ff96cdfc4fd6176f36f60fbe86dde1b3b6e4 Mon Sep 17 00:00:00 2001 From: mjfernez Date: Tue, 8 Jun 2021 11:18:04 -0400 Subject: Added ability to override templates. This commit primarily adds the ability to override the base template by adding a '!' on HTML files. It also makes adjustments to the index page display to not show this extra character. Additions to the README reflecting this change, as well as small note on similarity to neocities was added --- server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'server.py') diff --git a/server.py b/server.py index 21ecb2f..15514ba 100644 --- a/server.py +++ b/server.py @@ -121,8 +121,9 @@ def render_file(path): if abs_path.endswith('.html'): with open(abs_path) as f: content = f.read() - print(path.split('/')[-2] + '/') return render_template_string(CONTENT_BLOCK.replace('$', content), **context) + elif abs_path.endswith('.html!'): + return render_template("site/" + path, **context) else: # not an html file, so don't render it return send_from_directory('templates/site/', path, -- cgit v1.2.3