File size: 717 Bytes
dda557a | 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 | const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000'
export async function predictMRI(file) {
const form = new FormData()
form.append('file', file)
const res = await fetch(`${API_URL}/predict`, {
method: 'POST',
body: form,
})
if (!res.ok) {
const text = await res.text().catch(() => '')
throw new Error(text || `Request failed (${res.status})`)
}
return res.json()
}
export async function fetchHealth() {
const res = await fetch(`${API_URL}/health`)
if (!res.ok) throw new Error('Health check failed')
return res.json()
}
export async function fetchMetrics() {
const res = await fetch(`${API_URL}/metrics`)
if (!res.ok) return null
return res.json()
}
|