|
|
|
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
|
|
|
const API_BASE_URL = window.location.origin; |
|
|
|
|
|
|
|
|
async function checkApiStatus() { |
|
|
try { |
|
|
const response = await fetch(`${API_BASE_URL}/api/status`); |
|
|
const data = await response.json(); |
|
|
|
|
|
if (data.ready) { |
|
|
|
|
|
console.log('API μλ² μ€λΉ μλ£'); |
|
|
|
|
|
|
|
|
if (window.location.pathname === '/loading') { |
|
|
window.location.href = '/'; |
|
|
} |
|
|
|
|
|
return true; |
|
|
} else { |
|
|
|
|
|
console.log('API μλ² μ΄κΈ°ν μ€...'); |
|
|
|
|
|
|
|
|
if (window.location.pathname !== '/loading') { |
|
|
window.location.href = '/loading'; |
|
|
} |
|
|
|
|
|
return false; |
|
|
} |
|
|
} catch (err) { |
|
|
console.error('API μλ² μν νμΈ μ€ν¨:', err); |
|
|
|
|
|
|
|
|
const statusDisplay = document.getElementById('apiStatusDisplay'); |
|
|
if (statusDisplay) { |
|
|
statusDisplay.innerHTML = ` |
|
|
<div class="alert alert-danger"> |
|
|
<i class="fas fa-exclamation-triangle me-2"></i> |
|
|
API μλ²μ μ°κ²°ν μ μμ΅λλ€. μλ²κ° μ€ν μ€μΈμ§ νμΈνμΈμ. |
|
|
</div> |
|
|
`; |
|
|
} |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
checkApiStatus(); |
|
|
|
|
|
|
|
|
setInterval(checkApiStatus, 10000); |
|
|
}); |
|
|
|