| 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() | |
| } | |