Skip to content
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"route": "/api/logs",
"log_file": "server.log"
}
}
}
25 changes: 22 additions & 3 deletions python-api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
app = Flask(__name__)

# Chargement de la configuration partagée (config.json à la racine du projet)
config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'config.json')
with open(config_path, 'r') as f:
config_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "..", "config.json"
)
with open(config_path, "r") as f:
config = json.load(f)

# -------------------------------------------------------
Expand Down Expand Up @@ -36,10 +38,27 @@ def parse_logs(filepath):
"warning_count": len(warnings),
"info_count": len(infos),
"errors": errors,
"warnings": warnings
"warnings": warnings,
}


# Health check endpoint — returns the current status of the API service,
# including the project name, version, and port loaded from config.json
@app.route("/api/health", methods=["GET"])
def health():
return (
jsonify(
{
"status": "ok",
"service": config["projet"],
"version": config.get("version", "1.0.0"),
"port": config["api"]["port"],
}
),
200,
)


@app.route("/api/logs", methods=["GET"])
def get_logs():
result = parse_logs(config["api"]["log_file"])
Expand Down
Loading