Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login</title>
<link rel="stylesheet" href="style.css" />
</head>
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Django>=5.2,<6
duckduckgo_search>=8.1
1 change: 1 addition & 0 deletions search_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
28 changes: 28 additions & 0 deletions searcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import json
import time
from duckduckgo_search import DDGS

QUERY = (
"master thesis positions in stockholm for computing engineering students with masters degree in machine learning"
)
OUTPUT_FILE = "search_results.json"


def perform_search():
ddgs = DDGS()
results = list(ddgs.text(QUERY, max_results=10))
with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
json.dump(results, f, ensure_ascii=False, indent=2)


def main():
while True:
try:
perform_search()
except Exception as exc:
print(f"Search failed: {exc}")
time.sleep(60)


if __name__ == "__main__":
main()
38 changes: 36 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
min-height: 100vh;
color: #333;
padding: 1rem;
}

.card {
Expand All @@ -15,7 +16,8 @@ body {
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
text-align: center;
width: 300px;
width: 100%;
max-width: 400px;
}

.card h2 {
Expand Down Expand Up @@ -50,3 +52,35 @@ body {
color: red;
margin-top: 0.5rem;
}
#results {
margin-top: 1rem;
text-align: left;
}

.result-item {
display: flex;
align-items: center;
margin-bottom: 0.5rem;
gap: 0.5rem;
}

.result-item img {
width: 16px;
height: 16px;
margin-right: 0.5rem;
}

.result-item a {
flex: 1;
overflow-wrap: anywhere;
}

@media (max-width: 480px) {
.card {
padding: 1.5rem;
}

body {
padding: 0.5rem;
}
}
32 changes: 32 additions & 0 deletions welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Welcome</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="card">
<h2>Welcome!</h2>
<input type="text" id="searchInput" value="master thesis positions in stockholm for computing engineering students with masters degree in machine learning" />
<div id="results"></div>
<button id="logout">Log out</button>
</div>
<script>
Expand All @@ -18,6 +21,35 @@ <h2>Welcome!</h2>
localStorage.removeItem('loggedIn');
window.location.href = 'login.html';
});

const resultsDiv = document.getElementById('results');

async function loadResults() {
try {
const response = await fetch('search_results.json?_=' + Date.now());
const data = await response.json();
resultsDiv.innerHTML = '';
data.forEach(item => {
const container = document.createElement('div');
container.className = 'result-item';
const img = document.createElement('img');
const url = new URL(item.href);
img.src = 'https://www.google.com/s2/favicons?domain=' + url.hostname;
const link = document.createElement('a');
link.href = item.href;
link.textContent = item.title;
link.target = '_blank';
container.appendChild(img);
container.appendChild(link);
resultsDiv.appendChild(container);
});
} catch (e) {
console.error('Failed to load results', e);
}
}

loadResults();
setInterval(loadResults, 60000);
</script>
</body>
</html>