enotkrutoy commited on
Commit
9b4aad6
·
verified ·
1 Parent(s): 7945156

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +19 -55
templates/index.html CHANGED
@@ -1,64 +1,28 @@
1
  <!DOCTYPE html>
2
- <html lang="ru">
3
  <head>
4
- <meta charset="UTF-8">
5
- <title>Поиск кода через Searchcode API</title>
6
  <style>
7
- body { font-family: Arial, sans-serif; background: #f4f4f4; margin: 20px; }
8
- .container { width: 80%; margin: auto; background: #fff; padding: 20px; border-radius: 6px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
9
- input, button { padding: 10px; margin: 4px 0; }
10
- button { background: #007bff; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
11
- button:hover { background: #0056b3; }
12
- .result { border-bottom: 1px solid #ddd; padding: 10px 0; }
13
- pre { background: #eee; padding: 10px; border-radius: 4px; overflow-x: auto; }
14
  </style>
15
  </head>
16
  <body>
17
- <div class="container">
18
- <h1>Поиск кода через Searchcode API</h1>
19
- <form id="searchForm">
20
- <input type="text" name="q" placeholder="Введите запрос (например, soup)" value="soup" required><br>
21
- <input type="text" name="ext" placeholder="Расширение файла (например, py)">
22
- <input type="text" name="lang" placeholder="Язык (например, python)">
23
- <input type="text" name="repo" placeholder="Репозиторий (например, boyter/batf)">
24
- <button type="submit">Поиск</button>
25
- </form>
26
- <div id="results" style="margin-top: 20px;"></div>
27
- </div>
28
 
29
- <script>
30
- document.getElementById("searchForm").addEventListener("submit", function(e) {
31
- e.preventDefault();
32
- const formData = new FormData(e.target);
33
- const params = new URLSearchParams(formData);
34
-
35
- fetch("/search?" + params.toString())
36
- .then(response => response.json())
37
- .then(data => {
38
- const resultsDiv = document.getElementById("results");
39
- resultsDiv.innerHTML = "";
40
-
41
- if (data.results.length === 0) {
42
- resultsDiv.innerHTML = "<p>Нет результатов.</p>";
43
- } else {
44
- // Выводим основные параметры ответа
45
- resultsDiv.innerHTML = `<p><strong>Запрос:</strong> ${data.query}</p>
46
- <p><strong>Всего результатов:</strong> ${data.total}</p>`;
47
-
48
- data.results.forEach(item => {
49
- const div = document.createElement("div");
50
- div.classList.add("result");
51
- div.innerHTML = `<strong>${item.filename || 'Нет данных'} (строка: ${item.lines ? Object.keys(item.lines)[0] : 'N/A'})</strong>
52
- <pre>${item.lines ? Object.values(item.lines).join("\n") : 'Нет кода'}</pre>
53
- <a href="${item.url}" target="_blank">Посмотреть в Searchcode</a>`;
54
- resultsDiv.appendChild(div);
55
- });
56
- }
57
- })
58
- .catch(error => {
59
- console.error("Ошибка:", error);
60
- });
61
- });
62
- </script>
63
  </body>
64
  </html>
 
1
  <!DOCTYPE html>
2
+ <html>
3
  <head>
4
+ <title>Site Info Scanner</title>
 
5
  <style>
6
+ body { font-family: Arial, sans-serif; margin: 40px; }
7
+ input[type=text] { width: 300px; padding: 5px; }
8
+ input[type=submit] { padding: 5px 10px; }
9
+ pre { background: #f4f4f4; padding: 10px; border: 1px solid #ccc; }
 
 
 
10
  </style>
11
  </head>
12
  <body>
13
+ <h1>Site Info Scanner</h1>
14
+ <form method="post">
15
+ <input type="text" name="url" placeholder="https://example.com" required>
16
+ <input type="submit" value="Scan">
17
+ </form>
 
 
 
 
 
 
18
 
19
+ {% if error %}
20
+ <p style="color: red;">{{ error }}</p>
21
+ {% endif %}
22
+
23
+ {% if result %}
24
+ <h2>Scan Results:</h2>
25
+ <pre>{{ result | tojson(indent=4) }}</pre>
26
+ {% endif %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  </body>
28
  </html>