30 lines
885 B
JavaScript
30 lines
885 B
JavaScript
document.getElementById('analyzeBtn').addEventListener('click', () => {
|
|
const url = document.getElementById('urlInput').value;
|
|
const resultDiv = document.getElementById('result');
|
|
|
|
if (url) {
|
|
resultDiv.textContent = 'Analyzing...';
|
|
fetch('http://127.0.0.1:8000/api/analyze/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({ content: url }),
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.status === 'ok') {
|
|
resultDiv.textContent = `Analysis: ${data.message}`;
|
|
} else {
|
|
resultDiv.textContent = `Error: ${data.message}`;
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
resultDiv.textContent = 'An error occurred during analysis.';
|
|
});
|
|
} else {
|
|
resultDiv.textContent = 'Please enter a URL.';
|
|
}
|
|
});
|