Toutes les app sur les cotés

This commit is contained in:
para
2026-09-25 00:02:53 +02:00
parent 455988e49c
commit 93dcf514d2
5 changed files with 262 additions and 132 deletions
+23
View File
@@ -10,6 +10,9 @@ import shutil
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from yunohost_sync import build_app_list, fetch_remote_apps, known_urls, load_env, sync_target
PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 8000
SCRIPT_DIR = Path(__file__).resolve().parent
@@ -71,6 +74,10 @@ class ReloadingHandler(http.server.SimpleHTTPRequestHandler):
self.wfile.write(body)
return
if self.path == "/__catalog":
self._send_catalog()
return
if self.path in ("/", "/index.html"):
try:
html = (SRC_DIR / "index.html").read_bytes()
@@ -114,6 +121,22 @@ class ReloadingHandler(http.server.SimpleHTTPRequestHandler):
self.send_error(404)
def _send_catalog(self):
env = load_env()
ssh_target, domain, self_app_id = sync_target(env)
if not ssh_target or not domain:
self._send_json({"error": "SYNC_SSH_HOST (ou REMOTE_HOST) et PORTAL_DOMAIN manquants dans .env"})
return
try:
with open(SRC_DIR / "config.json", encoding="utf-8") as f:
config = json.load(f)
remote = fetch_remote_apps(ssh_target, domain)
apps = build_app_list(remote, domain, self_app_id, exclude_urls=known_urls(config))
except Exception as exc: # SSH/JSON/reseau : on remonte un message lisible
self._send_json({"error": str(exc)})
return
self._send_json({"apps": apps})
def _send_json(self, payload):
body = json.dumps(payload).encode()
self.send_response(200)