Echo-ai commited on
Commit
f938b97
·
verified ·
1 Parent(s): 8d3a135

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +92 -0
templates/index.html ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>In-Depth Research</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8
+ <style>
9
+ body {
10
+ background-color: #f8f9fa;
11
+ padding-top: 50px;
12
+ }
13
+ .search-container {
14
+ max-width: 600px;
15
+ margin: auto;
16
+ }
17
+ .result-container {
18
+ max-width: 800px;
19
+ margin: 20px auto;
20
+ padding: 20px;
21
+ background-color: #ffffff;
22
+ border-radius: 10px;
23
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
24
+ }
25
+ .loader {
26
+ border: 8px solid #f3f3f3;
27
+ border-top: 8px solid #3498db;
28
+ border-radius: 50%;
29
+ width: 60px;
30
+ height: 60px;
31
+ animation: spin 2s linear infinite;
32
+ margin: auto;
33
+ }
34
+ @keyframes spin {
35
+ 0% { transform: rotate(0deg); }
36
+ 100% { transform: rotate(360deg); }
37
+ }
38
+ </style>
39
+ </head>
40
+ <body>
41
+ <div class="container text-center">
42
+ <h1>In-Depth Research</h1>
43
+ <div class="search-container">
44
+ <form id="search-form">
45
+ <div class="input-group mb-3">
46
+ <input type="text" id="query" class="form-control" placeholder="Enter your research topic" aria-label="Research Topic" aria-describedby="button-addon2">
47
+ <button class="btn btn-primary" type="submit" id="button-addon2">Search</button>
48
+ </div>
49
+ </form>
50
+ <div id="loader" class="loader d-none"></div>
51
+ <div id="result" class="result-container d-none"></div>
52
+ </div>
53
+ </div>
54
+
55
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.6.1/socket.io.min.js" integrity="sha512-SU1kM0R8P4/5Qv4i7iXK8Fc6b0C6p6r1J5x9tH+7vqYvq9Zx7n0F9I/5g0ly2+4m6k4t1q1jX4k9g9J1A6a1eG3kQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
56
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
57
+ <script>
58
+ const socket = io();
59
+
60
+ document.getElementById('search-form').addEventListener('submit', function(e) {
61
+ e.preventDefault();
62
+ const query = document.getElementById('query').value;
63
+ if (!query) {
64
+ alert('Please enter a research topic.');
65
+ return;
66
+ }
67
+
68
+ // Show the loader and hide the result
69
+ document.getElementById('loader').classList.remove('d-none');
70
+ document.getElementById('result').classList.add('d-none');
71
+ document.getElementById('result').innerHTML = '';
72
+
73
+ // Emit the search event
74
+ socket.emit('search', {'query': query});
75
+ });
76
+
77
+ // Listen for the result event
78
+ socket.on('result', function(data) {
79
+ document.getElementById('loader').classList.add('d-none');
80
+ if (data.error) {
81
+ document.getElementById('result').innerHTML = `<p class="text-danger">Error: ${data.error}</p>`;
82
+ } else {
83
+ document.getElementById('result').innerHTML = `
84
+ <h2>${data.query}</h2>
85
+ <p>${data.result}</p>
86
+ `;
87
+ }
88
+ document.getElementById('result').classList.remove('d-none');
89
+ });
90
+ </script>
91
+ </body>
92
+ </html>