From dda4bc870d00b5eed93c6adfed3762bc3d917bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Mon, 11 Nov 2024 00:21:26 -0500 Subject: [PATCH] Chemins relatifs pour les formats --- routers/format_styles.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/routers/format_styles.py b/routers/format_styles.py index 2c09f9f..1a31172 100644 --- a/routers/format_styles.py +++ b/routers/format_styles.py @@ -1,5 +1,6 @@ import json import logging +import os from typing import Annotated from fastapi import APIRouter, Depends @@ -14,18 +15,18 @@ router = APIRouter() @router.get("/styles/") async def get_styles(current_user: Annotated[User, Depends(get_current_active_user)]): - styles = Styles(styles=list_dir("../styles")) + styles = Styles(styles=list_dir("{os.getcwd()}/styles")) return styles @router.get("/formats/{style}/") async def get_formats(style: str, current_user: Annotated[User, Depends(get_current_active_user)]): - formats = Formats(formats=list_dir(f"./styles/{style}/")) + formats = Formats(formats=list_dir(f"{os.getcwd()}/styles/{style}/")) return formats @router.get("/format_parameters/{style}/{format}/") async def get_format_parameters(style: str, format: str, current_user: Annotated[User, Depends(get_current_active_user)]): # open styles/format_parameters.json as a dictionary - with open(f"./styles/{style}/format_parameters.json", "r") as f: + with open(f"{os.getcwd()}/styles/{style}/format_parameters.json", "r") as f: format_data = json.load(f).get(format) logging.info(str(format_data)) # load data from format_data into the FormatParameters object