gijl commited on
Commit
839d4e5
·
verified ·
1 Parent(s): 5a9400a

Delete index.html

Browse files
Files changed (1) hide show
  1. index.html +0 -87
index.html DELETED
@@ -1,87 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="ar" dir="rtl">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Gemma Vision Model</title>
7
- <script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
8
- <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
9
- <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
10
- <style>
11
- body { font-family: system-ui, sans-serif; padding: 20px; max-width: 800px; margin: 0 auto; background: #f9fafb; }
12
- .container { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
13
- input, button { padding: 12px; margin: 10px 0; border-radius: 5px; border: 1px solid #ccc; width: 100%; box-sizing: border-box; font-size: 16px;}
14
- button { background: #3b82f6; color: white; border: none; cursor: pointer; font-weight: bold; }
15
- button:disabled { background: #9ca3af; cursor: not-allowed; }
16
- .result { margin-top: 20px; padding: 15px; background: #f3f4f6; border-radius: 5px; white-space: pre-wrap; direction: ltr; text-align: left; }
17
- </style>
18
- </head>
19
- <body>
20
- <div id="root"></div>
21
-
22
- <script type="text/babel">
23
- function App() {
24
- const [image, setImage] = React.useState(null);
25
- const [text, setText] = React.useState("Describe this image.");
26
- const [result, setResult] = React.useState("");
27
- const [loading, setLoading] = React.useState(false);
28
-
29
- const handleSubmit = async (e) => {
30
- e.preventDefault();
31
- if (!image) { alert("الرجاء رفع صورة أولاً"); return; }
32
-
33
- setLoading(true);
34
- setResult("");
35
-
36
- const formData = new FormData();
37
- formData.append("image", image);
38
- formData.append("text", text);
39
-
40
- try {
41
- const response = await fetch("/generate", {
42
- method: "POST",
43
- body: formData
44
- });
45
- const data = await response.json();
46
-
47
- if (response.ok) {
48
- setResult(data.result);
49
- } else {
50
- setResult("خطأ من الخادم: " + data.detail);
51
- }
52
- } catch (error) {
53
- setResult("فشل الاتصال بالخادم.");
54
- }
55
- setLoading(false);
56
- };
57
-
58
- return (
59
- <div className="container">
60
- <h2>نموذج Gemma لتحليل الصور (واجهة React)</h2>
61
- <form onSubmit={handleSubmit}>
62
- <label>رفع الصورة:</label>
63
- <input type="file" accept="image/*" onChange={e => setImage(e.target.files[0])} />
64
-
65
- <label>السؤال أو الطلب:</label>
66
- <input type="text" value={text} onChange={e => setText(e.target.value)} />
67
-
68
- <button type="submit" disabled={loading}>
69
- {loading ? "جاري المعالجة... (قد يستغرق وقتاً)" : "إرسال وتحليل"}
70
- </button>
71
- </form>
72
-
73
- {result && (
74
- <div className="result">
75
- <strong>النتيجة:</strong><br/><br/>
76
- {result}
77
- </div>
78
- )}
79
- </div>
80
- );
81
- }
82
-
83
- const root = ReactDOM.createRoot(document.getElementById('root'));
84
- root.render(<App />);
85
- </script>
86
- </body>
87
- </html>