15 lines
365 B
Python
15 lines
365 B
Python
import time
|
|
from fastapi.responses import JSONResponse
|
|
from app.utils.logger_util import logger
|
|
|
|
|
|
def response(data: dict, start_time: float, code: int = 200) -> dict:
|
|
speed = time.time() - start_time
|
|
data["duration"] = speed
|
|
|
|
logger.debug(f"RESPONSE TIME: {speed}s")
|
|
|
|
if code != 200:
|
|
return JSONResponse(content=data, status_code=code)
|
|
|
|
return data |