ADD base domain information on Index page and API endpoint

This commit is contained in:
CaffeineFueled 2025-04-09 19:54:24 +02:00
parent fc72f6f51c
commit 7db919bcb7
3 changed files with 270 additions and 27 deletions

View file

@ -61,6 +61,23 @@
font-size: 0.9em;
color: #0f5132;
}
.base-domain-badge {
display: inline-block;
padding: 3px 7px;
background-color: #cfe2ff;
border-radius: 4px;
font-size: 0.9em;
color: #0a58ca;
}
.same-domain-badge {
display: inline-block;
padding: 3px 7px;
background-color: #e9ecef;
border-radius: 4px;
font-size: 0.9em;
color: #6c757d;
font-style: italic;
}
.api-section {
margin-top: 30px;
padding: 15px;
@ -127,12 +144,48 @@
}
.filter-form {
margin-bottom: 20px;
background-color: #f9f9f9;
padding: 15px;
border-radius: 5px;
}
.filter-row {
display: flex;
flex-wrap: wrap;
gap: 15px;
align-items: flex-end;
}
.filter-group {
display: flex;
flex-direction: column;
}
.filter-group label {
font-weight: bold;
margin-bottom: 5px;
font-size: 0.9em;
}
.filter-select {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
margin-right: 10px;
min-width: 150px;
}
.btn-sm {
padding: 8px 16px;
font-size: 0.9em;
}
.reset-button {
display: inline-block;
padding: 8px 16px;
background-color: #f44336;
color: white;
text-decoration: none;
border-radius: 4px;
font-weight: bold;
font-size: 0.9em;
}
.reset-button:hover {
background-color: #e53935;
color: white;
}
</style>
</head>
@ -199,15 +252,32 @@
<div class="filter-form">
<h2>Domain List</h2>
<form id="filterForm" method="get">
<label for="upload_filter">Filter by upload:</label>
<select id="upload_filter" name="upload_id" class="filter-select" onchange="this.form.submit()">
<option value="">All uploads</option>
{% for upload in uploads %}
<option value="{{ upload.id }}" {% if request.query_params.get('upload_id') == upload.id %}selected{% endif %}>
{{ upload.filename }} - {{ upload.timestamp.replace('T', ' ').split('.')[0] }}
</option>
{% endfor %}
</select>
<div class="filter-row">
<div class="filter-group">
<label for="upload_filter">Filter by upload:</label>
<select id="upload_filter" name="upload_id" class="filter-select">
<option value="">All uploads</option>
{% for upload in uploads %}
<option value="{{ upload.id }}" {% if request.query_params.get('upload_id') == upload.id %}selected{% endif %}>
{{ upload.filename }} - {{ upload.timestamp.replace('T', ' ').split('.')[0] }}
</option>
{% endfor %}
</select>
</div>
<div class="filter-group">
<label for="base_domains_only">Show base domains only:</label>
<select id="base_domains_only" name="base_domains_only" class="filter-select">
<option value="false" {% if request.query_params.get('base_domains_only', 'false') == 'false' %}selected{% endif %}>No (Show All)</option>
<option value="true" {% if request.query_params.get('base_domains_only') == 'true' %}selected{% endif %}>Yes (example.com only)</option>
</select>
</div>
<div class="filter-buttons">
<button type="submit" class="btn btn-sm">Apply Filters</button>
<a href="/" class="reset-button">Reset</a>
</div>
</div>
</form>
</div>
@ -215,8 +285,10 @@
<h3>API Endpoints</h3>
<p>Get all uploads: <code>/api/uploads</code></p>
<p>Get all domains: <code>/api/domains</code></p>
<p>Get only base domains: <code>/api/base-domains</code> (simplified format: <code>{"domain": "example.com", "timestamp": "..."}</code>)</p>
<p>Get domains by name: <code>/api/domains/{domain}</code></p>
<p>Filter by upload: <code>/api/domains?upload_id={upload_id}</code></p>
<p>Show base domains only: <code>/api/domains?base_domains_only=true</code></p>
</div>
{% if domains %}
@ -225,6 +297,9 @@
<thead>
<tr>
<th>Domain</th>
{% if not base_domains_only %}
<th>Base Domain</th>
{% endif %}
<th>Upload Date</th>
</tr>
</thead>
@ -232,6 +307,9 @@
{% for item in domains %}
<tr>
<td><span class="domain-badge">{{ item.full_domain }}</span></td>
{% if not base_domains_only %}
<td>{% if item.base_domain != item.full_domain %}<span class="base-domain-badge">{{ item.base_domain }}</span>{% else %}<span class="same-domain-badge">Same as domain</span>{% endif %}</td>
{% endif %}
<td>{{ item.timestamp.replace('T', ' ').split('.')[0] if item.get('timestamp') else 'N/A' }}</td>
</tr>
{% endfor %}