generated from hjess/PythonTemplateProject
[main] Lidt mere context
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 45s
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 45s
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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)
|
||||
|
||||
|
||||
Binary file not shown.
@@ -120,3 +120,4 @@ class MetadataProcessor:
|
||||
json.dump( self.data, json_file, indent = 4, ensure_ascii = False )
|
||||
|
||||
print( f"Generated JSON saved to {self.output_file}" )
|
||||
return True
|
||||
Reference in New Issue
Block a user