From 24cdb8f6201a825aea1d258a99ba2b1b31ae5846 Mon Sep 17 00:00:00 2001 From: Ayo Ayco Date: Sat, 18 May 2024 22:23:12 +0200 Subject: [PATCH] refactor: remove partials feature --- README.md | 3 +-- partials.py | 17 ----------------- partials/example.html | 1 - web.py | 2 -- 4 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 partials.py delete mode 100644 partials/example.html diff --git a/README.md b/README.md index f929d67..936d70a 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,8 @@ This is the default server running at [https://ayo.ayco.io](https://ayco.io). Its main responsibility is serving static files generated with Astro SSG which I maintain in a [separate project](https://ayco.io/sh/ayco.io-astro). The generated files from that project will populate a `dist` directory in here, which will then be served as-is. Additional features are: -1. route `/p/*` to serve partial .html templates in `partials` directory (e.g, `partials/example.html` partial is accessed via `/p/example`) 1. attach [/threads](https://ayco.io/sh/threads) flask blueprint behind `/threads` route - +1. perf monitoring and error tracking with [sentry.io](https://sentry.io) > [!IMPORTANT] > The overall architecture is still experimental. The way I decoupled the dynamic tiny apps here (e.g., [/threads](https://ayco.io/sh/threads), and [ori](https://ayco.io/sh/ori)) is good, but an improvement in this project still needs to be made with regards to managing a common app configuration that the blueprints consume, packaging the software components into modules for better distribution & adoption, and providing various deployment options. diff --git a/partials.py b/partials.py deleted file mode 100644 index a896253..0000000 --- a/partials.py +++ /dev/null @@ -1,17 +0,0 @@ -from flask import Blueprint, render_template, send_from_directory -from jinja2 import TemplateNotFound -from datetime import datetime - -partials = Blueprint('partials', __name__, template_folder='partials') - -@partials.route('/', defaults={'page': 'index'}) -@partials.route('/') -def show(page): - try: - return render_template(f'{page}.html') - except TemplateNotFound: - return send_from_directory('dist', '404.html'), 404 - -@partials.route('example') -def example(): - return render_template(f'example.html', date=datetime.now().strftime('%B %d, %Y')) diff --git a/partials/example.html b/partials/example.html deleted file mode 100644 index 2f1c4f6..0000000 --- a/partials/example.html +++ /dev/null @@ -1 +0,0 @@ -

Hey! Today is {{ date }}. Nothing to see here. I'm just currently experimenting on using server-rendered dynamic partials in an iframe.

diff --git a/web.py b/web.py index 35f56fb..163c542 100755 --- a/web.py +++ b/web.py @@ -2,11 +2,9 @@ from flask import Flask, send_from_directory from flask_caching import Cache import sentry_sdk import json -from partials import partials from threads.threads import threads app = Flask(__name__) -app.register_blueprint(partials, url_prefix='/p') app.register_blueprint(threads, url_prefix='/threads') app.config.from_file("config.json", load=json.load)