Spaces:
Build error
Build error
Upload index.html
Browse files- templates/index.html +99 -1
templates/index.html
CHANGED
|
@@ -1 +1,99 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ru">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Распознаватель Капчи</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background-color: #f4f7f9; color: #333; margin: 0; padding: 20px; }
|
| 9 |
+
.container { max-width: 900px; margin: 0 auto; }
|
| 10 |
+
header { background-color: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 20px; text-align: center; }
|
| 11 |
+
h1 { margin: 0; color: #2c3e50; }
|
| 12 |
+
#solve-btn { background-color: #3498db; color: white; border: none; padding: 12px 24px; font-size: 16px; border-radius: 5px; cursor: pointer; transition: background-color 0.3s; }
|
| 13 |
+
#solve-btn:disabled { background-color: #bdc3c7; cursor: not-allowed; }
|
| 14 |
+
#spinner { display: none; margin-left: 15px; border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 24px; height: 24px; animation: spin 1s linear infinite; vertical-align: middle; }
|
| 15 |
+
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
| 16 |
+
.captcha-history { display: flex; flex-direction: column; gap: 20px; }
|
| 17 |
+
.captcha-card { background-color: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); padding: 20px; }
|
| 18 |
+
.captcha-card h3 { margin-top: 0; border-bottom: 1px solid #ecf0f1; padding-bottom: 10px; }
|
| 19 |
+
.images-container { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 20px; margin-top: 15px; }
|
| 20 |
+
.image-wrapper { text-align: center; }
|
| 21 |
+
.image-wrapper img { max-width: 100%; height: auto; border: 1px solid #ddd; border-radius: 4px; }
|
| 22 |
+
.image-wrapper p { font-size: 14px; color: #7f8c8d; margin-top: 5px; }
|
| 23 |
+
</style>
|
| 24 |
+
</head>
|
| 25 |
+
<body>
|
| 26 |
+
<div class="container">
|
| 27 |
+
<header>
|
| 28 |
+
<h1>Распознаватель Капчи EGE</h1>
|
| 29 |
+
<button id="solve-btn">Распознать новую капчу</button>
|
| 30 |
+
<div id="spinner"></div>
|
| 31 |
+
</header>
|
| 32 |
+
|
| 33 |
+
<div class="captcha-history" id="captcha-history">
|
| 34 |
+
{% for captcha in captchas %}
|
| 35 |
+
<div class="captcha-card">
|
| 36 |
+
<h3>Распознано: {{ captcha.text }}</h3>
|
| 37 |
+
<div class="images-container">
|
| 38 |
+
<div class="image-wrapper">
|
| 39 |
+
<p>Оригинал</p>
|
| 40 |
+
<img src="data:image/png;base64,{{ captcha.original_b64 }}" alt="Original Captcha">
|
| 41 |
+
</div>
|
| 42 |
+
<div class="image-wrapper">
|
| 43 |
+
<p>Обработанное</p>
|
| 44 |
+
<img src="data:image/png;base64,{{ captcha.processed_b64 }}" alt="Processed Captcha">
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
{% endfor %}
|
| 49 |
+
</div>
|
| 50 |
+
</div>
|
| 51 |
+
|
| 52 |
+
<script>
|
| 53 |
+
const solveBtn = document.getElementById('solve-btn');
|
| 54 |
+
const historyContainer = document.getElementById('captcha-history');
|
| 55 |
+
const spinner = document.getElementById('spinner');
|
| 56 |
+
|
| 57 |
+
solveBtn.addEventListener('click', async () => {
|
| 58 |
+
solveBtn.disabled = true;
|
| 59 |
+
spinner.style.display = 'inline-block';
|
| 60 |
+
|
| 61 |
+
try {
|
| 62 |
+
const response = await fetch('/solve', { method: 'POST' });
|
| 63 |
+
if (!response.ok) {
|
| 64 |
+
throw new Error('Ошибка сети или сервера');
|
| 65 |
+
}
|
| 66 |
+
const data = await response.json();
|
| 67 |
+
|
| 68 |
+
if (data.error) {
|
| 69 |
+
alert(data.error);
|
| 70 |
+
} else {
|
| 71 |
+
const newCaptchaCard = `
|
| 72 |
+
<div class="captcha-card">
|
| 73 |
+
<h3>Распознано: ${data.text}</h3>
|
| 74 |
+
<div class="images-container">
|
| 75 |
+
<div class="image-wrapper">
|
| 76 |
+
<p>Оригинал</p>
|
| 77 |
+
<img src="data:image/png;base64,${data.original_b64}" alt="Original Captcha">
|
| 78 |
+
</div>
|
| 79 |
+
<div class="image-wrapper">
|
| 80 |
+
<p>Обработанное</p>
|
| 81 |
+
<img src="data:image/png;base64,${data.processed_b64}" alt="Processed Captcha">
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
`;
|
| 86 |
+
historyContainer.insertAdjacentHTML('afterbegin', newCaptchaCard);
|
| 87 |
+
}
|
| 88 |
+
} catch (error) {
|
| 89 |
+
console.error('Ошибка при запросе новой капчи:', error);
|
| 90 |
+
alert('Не удалось получить новую капчу. Попробуйте снова.');
|
| 91 |
+
} finally {
|
| 92 |
+
solveBtn.disabled = false;
|
| 93 |
+
spinner.style.display = 'none';
|
| 94 |
+
}
|
| 95 |
+
});
|
| 96 |
+
</script>
|
| 97 |
+
</body>
|
| 98 |
+
</html>
|
| 99 |
+
|