Преглед изворни кода

Upload files to 'Supportgpt/templates'

SadhulaSaiKumar пре 1 година
родитељ
комит
5a79c0d1e7
1 измењених фајлова са 219 додато и 0 уклоњено
  1. 219
    0
      Supportgpt/templates/index.html

+ 219
- 0
Supportgpt/templates/index.html Прегледај датотеку

@@ -0,0 +1,219 @@
1
+<!-- <!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+    <meta charset="UTF-8">
5
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+    <title>Question Form</title>
7
+    <style>
8
+        body {
9
+            font-family: Arial, sans-serif;
10
+            margin: 0;
11
+            padding: 0;
12
+        }
13
+
14
+        .form-container {
15
+            max-width: 400px;
16
+            margin: 50px auto;
17
+            padding: 20px;
18
+            border: 1px solid #ccc;
19
+            border-radius: 5px;
20
+        }
21
+
22
+        label {
23
+            display: block;
24
+            margin-bottom: 8px;
25
+        }
26
+
27
+        input {
28
+            width: 100%;
29
+            padding: 8px;
30
+            margin-bottom: 16px;
31
+            box-sizing: border-box;
32
+        }
33
+
34
+        textarea {
35
+            width: 100%;
36
+            height: 100px;
37
+            padding: 8px;
38
+            margin-bottom: 16px;
39
+            box-sizing: border-box;
40
+        }
41
+
42
+        button {
43
+            padding: 8px 16px;
44
+            background-color: #3498db;
45
+            color: #fff;
46
+            border: none;
47
+            border-radius: 3px;
48
+            cursor: pointer;
49
+        }
50
+
51
+        button:hover {
52
+            background-color: #2980b9;
53
+        }
54
+
55
+        .output-container {
56
+            margin-top: 20px;
57
+        }
58
+    </style>
59
+</head>
60
+<body>
61
+    <div class="form-container">
62
+        <form id="questionForm">
63
+            <label for="userId">User ID:</label>
64
+            <input type="text" id="userId" readonly>
65
+
66
+            <label for="question">Question:</label>
67
+            <textarea id="question" required></textarea>
68
+
69
+            <button type="button" onclick="handleSubmit()">Submit</button>
70
+        </form>
71
+
72
+        <div class="output-container">
73
+            <label for="output">Output:</label>
74
+            <textarea id="output" readonly></textarea>
75
+        </div>
76
+    </div>
77
+
78
+    <script>
79
+        function generateUserId() {
80
+            // Generate a random user ID
81
+            var userId = "User" + Math.floor(Math.random() * 10000);
82
+            document.getElementById("userId").value = userId;
83
+        }
84
+
85
+        function handleSubmit() {
86
+            // Get values from the form
87
+            var userId = document.getElementById("userId").value;
88
+            var question = document.getElementById("question").value;
89
+
90
+            // Make an AJAX request to the server
91
+            var xhr = new XMLHttpRequest();
92
+            xhr.open("POST", "/user_input", true);
93
+            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
94
+            xhr.onreadystatechange = function () {
95
+                if (xhr.readyState == 4 && xhr.status == 200) {
96
+                    // Parse the JSON response
97
+                    var response = JSON.parse(xhr.responseText);
98
+
99
+                    // Update the output textarea with question and answer
100
+                    var output = "Question: " + question + "\nAnswer: " + response.output;
101
+                    document.getElementById("output").value = output;
102
+                }
103
+            };
104
+            
105
+            // Send the request with user ID and question
106
+            xhr.send("user_input=" + encodeURIComponent(question) + "&session_id=" + encodeURIComponent(userId));
107
+        }
108
+
109
+        // Generate user ID on page load
110
+        window.onload = generateUserId;
111
+    </script>
112
+</body>
113
+</html> -->
114
+<!DOCTYPE html>
115
+<html lang="en">
116
+<head>
117
+    <meta charset="UTF-8">
118
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
119
+    <title>Question Form</title>
120
+    <style>
121
+        body {
122
+            font-family: Arial, sans-serif;
123
+            margin: 0;
124
+            padding: 0;
125
+        }
126
+
127
+        .form-container {
128
+            max-width: 400px;
129
+            margin: 50px auto;
130
+            padding: 20px;
131
+            border: 1px solid #ccc;
132
+            border-radius: 5px;
133
+        }
134
+
135
+        label {
136
+            display: block;
137
+            margin-bottom: 8px;
138
+        }
139
+
140
+        input {
141
+            width: 100%;
142
+            padding: 8px;
143
+            margin-bottom: 16px;
144
+            box-sizing: border-box;
145
+        }
146
+
147
+        textarea {
148
+            width: 100%;
149
+            height: 100px;
150
+            padding: 8px;
151
+            margin-bottom: 16px;
152
+            box-sizing: border-box;
153
+        }
154
+
155
+        button {
156
+            padding: 8px 16px;
157
+            background-color: #3498db;
158
+            color: #fff;
159
+            border: none;
160
+            border-radius: 3px;
161
+            cursor: pointer;
162
+        }
163
+
164
+        button:hover {
165
+            background-color: #2980b9;
166
+        }
167
+
168
+        .output-container {
169
+            margin-top: 20px;
170
+
171
+        }
172
+    </style>
173
+</head>
174
+<body>
175
+    <div class="form-container">
176
+        <form id="questionForm">
177
+            <label for="userId">User ID:</label>
178
+            <input type="text" id="userId" required>
179
+
180
+            <label for="question">Question:</label>
181
+            <textarea id="question" required></textarea>
182
+
183
+            <button type="button" onclick="handleSubmit()">Submit</button>
184
+        </form>
185
+
186
+        <div class="output-container">
187
+            <label for="output">Output:</label>
188
+            <textarea id="output" readonly></textarea>
189
+        </div>
190
+    </div>
191
+
192
+    <script>
193
+        function handleSubmit() {
194
+            // Get values from the form
195
+            var userId = document.getElementById("userId").value;
196
+            var question = document.getElementById("question").value;
197
+
198
+            // Make an AJAX request to the server
199
+            var xhr = new XMLHttpRequest();
200
+            xhr.open("POST", "/user_input", true);
201
+            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
202
+            xhr.onreadystatechange = function () {
203
+                if (xhr.readyState == 4 && xhr.status == 200) {
204
+                    // Parse the JSON response
205
+                    var response = JSON.parse(xhr.responseText);
206
+
207
+                    // Update the output textarea with question and answer
208
+                    var output = "Question: " + question + "\nAnswer: " + response.output;
209
+                    document.getElementById("output").value = output;
210
+                }
211
+            };
212
+            
213
+            // Send the request with user ID and question
214
+            xhr.send("user_input=" + encodeURIComponent(question) + "&session_id=" + encodeURIComponent(userId));
215
+        }
216
+    </script>
217
+</body>
218
+</html>
219
+

Loading…
Откажи
Сачувај