Spaces:
Running
Running
File size: 802 Bytes
7ce42c6 256e676 e43b170 256e676 e43b170 256e676 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
const apiBase = 'https://ucsturkey-flare.hf.space';
function apiPost(path, body) {
return fetch(`${apiBase}${path}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
}).then(res => {
if (!res.ok) {
return res.json().then(err => { throw err; });
}
return res.json();
});
}
function apiGet(path) {
return fetch(`${apiBase}${path}`)
.then(res => res.json());
}
function showResult(id, data) {
const el = document.getElementById(id);
if (data.detail) {
el.innerText = data.detail;
el.classList.add('text-danger');
} else {
el.innerText = data.message || JSON.stringify(data, null, 2);
el.classList.remove('text-danger');
}
}
|