[main] Lidt mere context
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 45s

This commit is contained in:
2025-01-03 09:52:21 +01:00
parent 9f7e431126
commit f8b216bea3
15 changed files with 192 additions and 55 deletions

View File

@@ -6,6 +6,9 @@ from fastapi.templating import Jinja2Templates
from fastapi.responses import JSONResponse
import time
from app.services.metadata_processor import MetadataProcessor
class CategoryController:
def __init__(self,data_file="generated_data.json"):
"""Initialize the controller."""
@@ -28,7 +31,10 @@ class CategoryController:
)
def _load_data(self, data_file):
"""Load JSON data from a file."""
"""Load JSON data from a file. If the file is missing, generate it."""
if not os.path.exists(data_file):
print(f"{data_file} not found. Generating JSON...")
self.generate_json() # Call the JSON generation method
with open(data_file, "r", encoding="utf-8") as file:
return json.load(file)