Add basic web app and API integration

This commit is contained in:
Jan Meinl
2026-05-16 20:39:27 +02:00
commit 802906f9d4
33 changed files with 4340 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
const API_BASE = "http://127.0.0.1:8080";
function getApiBase() {
return API_BASE;
}
function apiURL(path) {
const base = getApiBase();
if (!base) return path;
return base + path;
}
function wsURL(path) {
const base = getApiBase();
if (base) {
let u;
try { u = new URL(base); } catch (e) { return null; }
u.protocol = u.protocol === "https:" ? "wss:" : "ws:";
u.pathname = u.pathname.replace(/\/+$/, "") + path;
return u.toString();
}
const proto = location.protocol === "https:" ? "wss:" : "ws:";
return `${proto}//${location.host}${path}`;
}