start docs (AI) fix some caching logic
All checks were successful
Datadog Secrets Scanning / Datadog Static Analyzer (push) Successful in 9s
Datadog Software Composition Analysis / Datadog SBOM Generation and Upload (push) Successful in 15s
Datadog Static Analysis / Datadog Static Analyzer (push) Successful in 19s
Release / build (release) Successful in 39s
All checks were successful
Datadog Secrets Scanning / Datadog Static Analyzer (push) Successful in 9s
Datadog Software Composition Analysis / Datadog SBOM Generation and Upload (push) Successful in 15s
Datadog Static Analysis / Datadog Static Analyzer (push) Successful in 19s
Release / build (release) Successful in 39s
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
from pathlib import Path
|
||||
from src.config.config import Configuration
|
||||
from src.rendering.renderer import render_page, render_error_page
|
||||
from flask import send_file
|
||||
from flask import send_file, request
|
||||
from src.rendering.image import generate_thumbnail
|
||||
from functools import lru_cache
|
||||
import os
|
||||
|
||||
|
||||
@ -114,13 +113,15 @@ class RouteManager:
|
||||
if file_path.exists():
|
||||
# Check to see if the file is an image, if it is, render a thumbnail
|
||||
if file_path.suffix.lower() in [".jpg", ".jpeg", ".png", ".gif"]:
|
||||
max_width = request.args.get("max_width", default=2048, type=int)
|
||||
thumbnail_bytes, img_format = generate_thumbnail(
|
||||
str(file_path), 10, 2048
|
||||
str(file_path), 10, 2048, max_width
|
||||
)
|
||||
return (
|
||||
thumbnail_bytes,
|
||||
200,
|
||||
{"Content-Type": f"image/{img_format.lower()}"},
|
||||
{"Content-Type": f"image/{img_format.lower()}",
|
||||
"cache-control": "public, max-age=31536000"},
|
||||
)
|
||||
return send_file(file_path)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user