44 lines
1.3 KiB
HTML
44 lines
1.3 KiB
HTML
{% extends "base.html" %}
|
|
{% block content %}
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='style/admin.css') }}">
|
|
|
|
<h2>Unteraufgabe hinzufügen</h2>
|
|
<form class="form" id="form">
|
|
<label for="titel">Titel</label>
|
|
<input id="title" name="title" type="text" autocomplete="off" required autofocus>
|
|
|
|
<label for="artist">Artist</label>
|
|
<input id="artist" name="artist" type="text" autocomplete="off">
|
|
|
|
<label for="file">Datei</label>
|
|
<div class="file-upload">
|
|
<input id="file" name="file" type="file" accept="audio/*,.mp3,.wav,.flac,.ogg,.m4a" required>
|
|
<label for="file" class="file-button">Audiodatei wählen</label>
|
|
<span class="file-name" id="file-name">Keine Datei ausgewählt</span>
|
|
</div>
|
|
|
|
<button type="submit">Erstellen</button>
|
|
</form>
|
|
|
|
<script>
|
|
const form = document.getElementById("form");
|
|
form.addEventListener("submit", async (event) => {
|
|
event.preventDefault();
|
|
const res = await fetch("/api/admin/add", {
|
|
method: "POST",
|
|
body: new FormData(form),
|
|
});
|
|
const result = await res.json();
|
|
console.log(result);
|
|
});
|
|
|
|
const fileInput = document.getElementById("file");
|
|
const fileName = document.getElementById("file-name");
|
|
fileInput.addEventListener("change", () => {
|
|
fileName.textContent = fileInput.files.length
|
|
? fileInput.files[0].name
|
|
: "Keine Datei ausgewählt";
|
|
});
|
|
</script>
|
|
|
|
{% endblock %} |