refactor: remove partials feature
This commit is contained in:
parent
2a04803d41
commit
24cdb8f620
4 changed files with 1 additions and 22 deletions
|
@ -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.
|
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:
|
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. 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]
|
> [!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.
|
> 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.
|
||||||
|
|
17
partials.py
17
partials.py
|
@ -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('/<page>')
|
|
||||||
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'))
|
|
|
@ -1 +0,0 @@
|
||||||
<p>Hey! Today is {{ date }}. Nothing to see here. I'm just currently experimenting on using server-rendered dynamic partials in an iframe.</p>
|
|
2
web.py
2
web.py
|
@ -2,11 +2,9 @@ from flask import Flask, send_from_directory
|
||||||
from flask_caching import Cache
|
from flask_caching import Cache
|
||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
import json
|
import json
|
||||||
from partials import partials
|
|
||||||
from threads.threads import threads
|
from threads.threads import threads
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.register_blueprint(partials, url_prefix='/p')
|
|
||||||
app.register_blueprint(threads, url_prefix='/threads')
|
app.register_blueprint(threads, url_prefix='/threads')
|
||||||
app.config.from_file("config.json", load=json.load)
|
app.config.from_file("config.json", load=json.load)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue