workflow / templates /index.html
triflix's picture
Create templates/index.html
b4af4fe verified
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Triflix Realtime Backup</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container py-5">
<h1 class="mb-4">Upload a File for Realtime Backup</h1>
<form id="uploadForm" enctype="multipart/form-data">
<div class="mb-3">
<input class="form-control" type="file" name="file" required>
</div>
<button type="submit" class="btn btn-primary">Upload & Push</button>
</form>
<div id="status" class="mt-3"></div>
</div>
<script>
document.getElementById('uploadForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const statusDiv = document.getElementById('status');
try {
const res = await fetch('/upload', { method: 'POST', body: formData });
const json = await res.json();
statusDiv.innerText = json.status + ": " + json.path;
} catch(err) {
statusDiv.innerText = "Error: " + err;
}
});
</script>
</body>
</html>