Spaces:
Sleeping
Sleeping
File size: 929 Bytes
a641ed5 | 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 | // api/client.js — sve API pozive na Flask backend
const BASE = '/api'
async function request(method, path, body) {
const res = await fetch(`${BASE}${path}`, {
method,
headers: { 'Content-Type': 'application/json' },
body: body ? JSON.stringify(body) : undefined,
})
if (!res.ok) {
const err = await res.json().catch(() => ({}))
throw new Error(err.error || `HTTP ${res.status}`)
}
return res.json()
}
// Provjera statusa servera
export const checkHealth = () => request('GET', '/health')
// Analiza jednog isječka koda
export const analyzeCode = (code, language, filename) =>
request('POST', '/analyze', { code, language, filename })
// Analiza više kodova odjednom
export const analyzeBatch = (submissions) =>
request('POST', '/analyze-batch', { submissions })
// Matrica sličnosti
export const computeSimilarity = (submissions) =>
request('POST', '/similarity', { submissions })
|