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

Delete index.html

Browse files
Files changed (1) hide show
  1. index.html +0 -64
index.html DELETED
@@ -1,64 +0,0 @@
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>