use new convex db base class and remove code that is already into the base class
Build and Push Docker Container / build-and-push (push) Successful in 1m21s

This commit is contained in:
2025-12-22 11:43:05 +01:00
parent cdab1057cc
commit fefda61c0b
4 changed files with 26 additions and 307 deletions
+12 -28
View File
@@ -1,40 +1,24 @@
from my_modules.app.setup import LIMITER, cache
from my_modules.app.setup import LIMITER
from quart import Blueprint, send_from_directory, render_template, current_app
from datetime import datetime
from quart import Blueprint, send_from_directory, render_template, current_app, Response, redirect
basic_bp = Blueprint('basic', __name__)
@basic_bp.route('/favicon', methods=['GET'])
@basic_bp.route('/favicon.ico', methods=['GET'])
@LIMITER.exempt
async def favicon(cache_key:str='favicon'):
cache_favicon_name = await cache.get(cache_key)
if cache_favicon_name:
file_name = cache_favicon_name
else:
current_year = datetime.now().year
autumn_start = datetime(current_year, 9, 23)
autumn_end = datetime(current_year, 12, 21)
winter_start = datetime(current_year, 12, 21)
winter_end = datetime(current_year, 3, 20)
# Get the current date
current_date = datetime.now()
if autumn_start <= current_date <= autumn_end:
file_name = '1. autumn.gif'
elif current_date >= winter_start or current_date <= winter_end:
file_name = '2. winter.png'
else:
file_name = '0. default.svg'
await cache.set(cache_key, file_name, ttl=21600)
return await send_from_directory(current_app.static_folder, f'images/favicons/{file_name}')
async def favicon():
file_data = await current_app.convex.get_current_favicon()
return redirect(file_data['file_id'])
@basic_bp.route('/robots.txt', methods=['GET'])
@LIMITER.limit('3 per day')
async def robots():
return await send_from_directory(current_app.static_folder, f'robots.txt')
@basic_bp.route("/storage/<path:file_id>")
async def convex_storage_proxy(file_id:str):
return Response(
current_app.convex.stream_from_storage(file_id, add_api_path=True),
mimetype="application/octet-stream"
)