AnesKAM commited on
Commit
5fbedcf
·
verified ·
1 Parent(s): 732e18a

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +109 -0
index.html ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Gemini Emulator - Stable GPT-4</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
8
+ <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;700&display=swap" rel="stylesheet">
9
+ <style>
10
+ body { font-family: 'Cairo', sans-serif; background-color: #1e1e2e; color: #cdd6f4; height: 100vh; display: flex; flex-direction: column; margin: 0; }
11
+ .chat-container { max-width: 800px; width: 100%; margin: auto; background: #252538; border-radius: 15px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); overflow: hidden; display: flex; flex-direction: column; height: 85vh; }
12
+ .chat-header { background: #11111b; padding: 15px; text-align: center; border-bottom: 1px solid #45475a; }
13
+ .chat-messages { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }
14
+ .message { max-width: 75%; padding: 12px 16px; border-radius: 15px; margin-bottom: 5px; line-height: 1.6; white-space: pre-wrap; }
15
+ .message.user { background-color: #89b4fa; color: #11111b; align-self: flex-start; border-bottom-right-radius: 2px; }
16
+ .message.bot { background-color: #45475a; color: #cdd6f4; align-self: flex-end; border-bottom-left-radius: 2px; }
17
+ .chat-input-area { padding: 15px; background: #11111b; border-top: 1px solid #45475a; }
18
+ .input-group input { background: #313244; border: 1px solid #45475a; color: #cdd6f4; }
19
+ .input-group input:focus { background: #313244; color: #cdd6f4; box-shadow: none; border-color: #89b4fa; }
20
+ .btn-custom { background-color: #89b4fa; color: #11111b; font-weight: bold; }
21
+ .btn-custom:hover { background-color: #b4befe; }
22
+ ::-webkit-scrollbar { width: 6px; }
23
+ ::-webkit-scrollbar-track { background: #252538; }
24
+ ::-webkit-scrollbar-thumb { background: #45475a; border-radius: 10px; }
25
+ </style>
26
+ </head>
27
+ <body>
28
+
29
+ <div class="container d-flex flex-column justify-content-center align-items-center h-100">
30
+ <div class="chat-container my-3">
31
+ <div class="chat-header">
32
+ <h4 class="m-0 text-info">Gemini Emulator</h4>
33
+ <small class="text-muted">بنية تحتية بـ Flask - مجاني وآمن 100% بدون CORS</small>
34
+ </div>
35
+
36
+ <div class="chat-messages" id="chatMessages">
37
+ <div class="message bot">مرحباً يا أنس! الآن الشات يعمل عبر سيرفرك الخاص، مجاني تماماً وبدون أي طلب دفع للمستخدمين. كيف أساعدك؟</div>
38
+ </div>
39
+
40
+ <div class="chat-input-area">
41
+ <form id="chatForm" onsubmit="sendMessage(event)">
42
+ <div class="input-group">
43
+ <input type="text" id="userInput" class="form-control" placeholder="اكتب سؤالك هنا..." required autocomplete="off">
44
+ <button class="btn btn-custom" type="submit" id="sendBtn">إرسال</button>
45
+ </div>
46
+ </form>
47
+ </div>
48
+ </div>
49
+ </div>
50
+
51
+ <script>
52
+ async function sendMessage(event) {
53
+ event.preventDefault();
54
+
55
+ const inputField = document.getElementById('userInput');
56
+ const sendButton = document.getElementById('sendBtn');
57
+ const chatMessages = document.getElementById('chatMessages');
58
+ const userText = inputField.value.trim();
59
+
60
+ if (!userText) return;
61
+
62
+ appendMessage(userText, 'user');
63
+ inputField.value = '';
64
+
65
+ inputField.disabled = true;
66
+ sendButton.disabled = true;
67
+
68
+ const loadingMessageDiv = appendMessage('جاري التفكير... ⏳', 'bot');
69
+
70
+ try {
71
+ // نرسل الطلب داخلياً لنفس سيرفر الـ Flask عبر مسار /chat
72
+ const response = await fetch('/chat', {
73
+ method: 'POST',
74
+ headers: { 'Content-Type': 'application/json' },
75
+ body: JSON.stringify({ text: userText })
76
+ });
77
+
78
+ const data = await response.json();
79
+
80
+ if (data.reply) {
81
+ loadingMessageDiv.innerText = data.reply;
82
+ } else {
83
+ loadingMessageDiv.innerText = "❌ خطأ في السيرفر الخارجي.";
84
+ }
85
+
86
+ } catch (error) {
87
+ console.error(error);
88
+ loadingMessageDiv.innerText = "❌ تعذر الاتصال بالسيرفر الداخلي.";
89
+ loadingMessageDiv.style.color = "#f38ba8";
90
+ } finally {
91
+ inputField.disabled = false;
92
+ sendButton.disabled = false;
93
+ inputField.focus();
94
+ }
95
+ }
96
+
97
+ function appendMessage(text, sender) {
98
+ const chatMessages = document.getElementById('chatMessages');
99
+ const messageDiv = document.createElement('div');
100
+ messageDiv.classList.add('message', sender);
101
+ messageDiv.innerText = text;
102
+ chatMessages.appendChild(messageDiv);
103
+ chatMessages.scrollTop = chatMessages.scrollHeight;
104
+ return messageDiv;
105
+ }
106
+ </script>
107
+
108
+ </body>
109
+ </html>