add routes and upload functions

This commit is contained in:
2025-10-24 08:25:57 +02:00
parent 175f382ec0
commit 8c2259d1de
7 changed files with 583 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
from my_modules.app.setup import LIMITER, cache
from quart import Blueprint, send_from_directory, render_template, current_app
from datetime import datetime
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}')
@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')