Files
simple-nanoshare/routes/handeling/basics.py
T
daniel156161 6137121209
Build and Push Docker Container / build-and-push (push) Successful in 1m36s
update to get favicon from compontent by using the storage
2026-02-16 12:02:52 +01:00

30 lines
975 B
Python

from my_modules.app.setup import LIMITER
from my_modules.functions import is_valid_uuid
from quart import Blueprint, send_from_directory, current_app, Response, redirect, abort
basic_bp = Blueprint('basic', __name__)
@basic_bp.route('/favicon', methods=['GET'])
@basic_bp.route('/favicon.ico', methods=['GET'])
@LIMITER.exempt
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):
clean_file_id = file_id.split("?", 1)[0]
if not is_valid_uuid(clean_file_id):
return abort(404, "Not a valid uuid")
return Response(
current_app.convex.stream_from_storage(file_id, add_api_path=True),
mimetype="application/octet-stream"
)