webcrawler v0.1

This commit is contained in:
mkrieger 2024-11-13 18:40:55 +01:00
parent e2d9a197c0
commit 008e2bc274
18 changed files with 681 additions and 0 deletions

27
app/templates/base.html Normal file
View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
</head>
<body>
{% if current_user.is_authenticated %}
<header>
<nav>
<ul>
<li><a href="{{ url_for('auth.job_status') }}">Jobs</a></li>
<li><a href="{{ url_for('auth.upload') }}">Upload</a></li>
<li><a href="{{ url_for('auth.logout') }}">Logout</a></li>
</ul>
</nav>
</header>
{% endif %}
<div class="{% if request.endpoint in ['auth.login', 'auth.signup'] %}form-container{% else %}container{% endif %}">
{% block content %}{% endblock %}
</div>
</body>
</html>

61
app/templates/jobs.html Normal file
View file

@ -0,0 +1,61 @@
{% extends "base.html" %}
{% block content %}
<div class="table-container">
<h2>Ihre Aufträge</h2>
<table id="jobs-table">
<thead>
<tr>
<th>Dateiname</th>
<th>Status</th>
<th>Erstellt am</th>
<th>Ergebnis</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for job in jobs %}
<tr>
<td>{{ job.filename }}</td>
<td class="job-status">{{ job.status }}</td>
<td>{{ job.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</td>
<td>
{% if job.status == "Completed" %}
<a href="{{ url_for('auth.download_result', job_id=job.id) }}">Download</a>
{% else %}
Noch nicht verfügbar
{% endif %}
</td>
<td>
<form action="{{ url_for('auth.delete_job', job_id=job.id) }}" method="POST" style="display:inline;">
<button type="submit" class="delete-btn">Löschen</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<script>
// Periodische Aktualisierung des Jobstatus
setInterval(function() {
fetch('{{ url_for("auth.job_status") }}')
.then(response => response.text())
.then(html => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const newRows = doc.querySelectorAll('#jobs-table tbody tr');
const currentRows = document.querySelectorAll('#jobs-table tbody tr');
newRows.forEach((newRow, index) => {
const newStatus = newRow.querySelector('.job-status').textContent;
currentRows[index].querySelector('.job-status').textContent = newStatus;
const newResult = newRow.querySelector('td:nth-child(4)').innerHTML;
currentRows[index].querySelector('td:nth-child(4)').innerHTML = newResult;
});
});
}, 5000); // Aktualisierung alle 5 Sekunden
</script>
{% endblock %}

16
app/templates/login.html Normal file
View file

@ -0,0 +1,16 @@
{% extends "base.html" %}
{% block content %}
<div class="form-container">
<h2>Anmelden</h2>
<form method="POST">
<label for="username">Benutzername</label>
<input type="text" name="username" id="username" required>
<label for="password">Passwort</label>
<input type="password" name="password" id="password" required>
<button type="submit">Anmelden</button>
</form>
<p>Noch keinen Account? <a href="{{ url_for('auth.signup') }}">Registrieren</a></p>
</div>
{% endblock %}

16
app/templates/signup.html Normal file
View file

@ -0,0 +1,16 @@
{% extends "base.html" %}
{% block content %}
<div class="form-container">
<h2>Registrieren</h2>
<form method="POST">
<label for="username">Benutzername</label>
<input type="text" name="username" id="username" required>
<label for="password">Passwort</label>
<input type="password" name="password" id="password" required>
<button type="submit">Registrieren</button>
</form>
<p>Bereits registriert? <a href="{{ url_for('auth.login') }}">Login</a></p>
</div>
{% endblock %}

11
app/templates/upload.html Normal file
View file

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block content %}
<div class="form-container">
<h2>Datei hochladen</h2>
<form method="POST" enctype="multipart/form-data">
<label for="file">CSV-Datei:</label>
<input type="file" id="file" name="file" accept=".csv" required>
<button type="submit">Upload</button>
</form>
</div>
{% endblock %}