Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +32 -43
templates/index.html
CHANGED
|
@@ -1,53 +1,42 @@
|
|
| 1 |
-
<!
|
| 2 |
<html lang="ar">
|
| 3 |
<head>
|
| 4 |
-
<meta charset="
|
| 5 |
-
<title
|
| 6 |
-
<style>
|
| 7 |
-
body { font-family: Arial; text-align: center; padding: 30px; background: #f9f9f9; }
|
| 8 |
-
input[type=file] { margin: 20px 0; }
|
| 9 |
-
.card { display:inline-block; border:2px solid #ddd; border-radius:12px; padding:20px; margin:15px; width:260px; background:#fff; box-shadow:0 4px 10px rgba(0,0,0,0.1); }
|
| 10 |
-
img.preview { width: 300px; border-radius:10px; margin-top:20px; }
|
| 11 |
-
.error { color:red; font-weight:bold; margin-top:20px; }
|
| 12 |
-
</style>
|
| 13 |
</head>
|
| 14 |
<body>
|
| 15 |
-
<
|
| 16 |
-
<form
|
| 17 |
-
<input type="file" name="image" accept="image/*" required
|
| 18 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</form>
|
| 20 |
|
| 21 |
-
|
| 22 |
-
<div class="error">{{ error_msg }}</div>
|
| 23 |
-
{% endif %}
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
<div class="card">
|
| 45 |
-
<div>🌟 النموذج الثالث</div>
|
| 46 |
-
النتيجة: {{ result_3 }}<br>
|
| 47 |
-
الثقة: {{ confidence_3 }}
|
| 48 |
-
</div>
|
| 49 |
-
{% endif %}
|
| 50 |
-
</div>
|
| 51 |
-
{% endif %}
|
| 52 |
</body>
|
| 53 |
</html>
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
<html lang="ar">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<title>اختبار API Analyze</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
</head>
|
| 7 |
<body>
|
| 8 |
+
<h2>اختبار نقطة النهاية /api/analyze</h2>
|
| 9 |
+
<form id="f" enctype="multipart/form-data">
|
| 10 |
+
<input type="file" id="img" name="image" accept="image/*" required>
|
| 11 |
+
<br><br>
|
| 12 |
+
<label>API Key: </label>
|
| 13 |
+
<input type="text" id="key" value="hkhlasjoaj5464hjsks" style="width:300px;">
|
| 14 |
+
<br><br>
|
| 15 |
+
<button type="button" onclick="send()">إرسال</button>
|
| 16 |
</form>
|
| 17 |
|
| 18 |
+
<pre id="out" style="white-space:pre-wrap; border:1px solid #ccc; padding:10px;"></pre>
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
<script>
|
| 21 |
+
async function send(){
|
| 22 |
+
const f = document.getElementById('f');
|
| 23 |
+
const form = new FormData();
|
| 24 |
+
const file = document.getElementById('img').files[0];
|
| 25 |
+
if(!file){ alert("اختر ملف"); return; }
|
| 26 |
+
form.append('image', file);
|
| 27 |
|
| 28 |
+
const key = document.getElementById('key').value;
|
| 29 |
+
|
| 30 |
+
document.getElementById('out').textContent = "جارٍ الإرسال...";
|
| 31 |
+
|
| 32 |
+
const resp = await fetch('/api/analyze', {
|
| 33 |
+
method: 'POST',
|
| 34 |
+
headers: {'x-api-key': key},
|
| 35 |
+
body: form
|
| 36 |
+
});
|
| 37 |
+
const data = await resp.json();
|
| 38 |
+
document.getElementById('out').textContent = JSON.stringify(data, null, 2);
|
| 39 |
+
}
|
| 40 |
+
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
</body>
|
| 42 |
</html>
|