Spaces:
Paused
Paused
| 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'); | |
| } | |
| } | |