Site-info front

This commit is contained in:
Djeex
2025-08-17 13:52:25 +02:00
parent 5a6f08644a
commit b74f1bb350
4 changed files with 330 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import logging
import yaml
from pathlib import Path
from flask import Flask, jsonify, request, send_from_directory, render_template
from src.py.builder.gallery_builder import (
@ -18,6 +19,8 @@ app = Flask(
static_url_path=""
)
SITE_YAML = Path(__file__).resolve().parents[3] / "config" / "site.yaml"
# --- Photos directory (configurable) ---
PHOTOS_DIR = Path(__file__).resolve().parents[3] / "config" / "photos"
app.config["PHOTOS_DIR"] = PHOTOS_DIR
@ -133,6 +136,25 @@ def photos(section, filename):
"""Serve uploaded photos from disk."""
return send_from_directory(PHOTOS_DIR / section, filename)
@app.route("/site-info")
def site_info():
return render_template("site-info/index.html")
@app.route("/api/site-info", methods=["GET"])
def get_site_info():
with open(SITE_YAML, "r") as f:
data = yaml.safe_load(f)
return jsonify(data)
@app.route("/api/site-info", methods=["POST"])
def update_site_info():
data = request.json
with open(SITE_YAML, "w") as f:
yaml.safe_dump(data, f, sort_keys=False, allow_unicode=True)
return jsonify({"status": "ok"})
# --- Run server ---
if __name__ == "__main__":
logging.info("Starting WebUI at http://127.0.0.1:5000")