katdrop/index.html
oiupoyt-mc 2cf02d43bc
Create index.html
idk what am i supposed to do
2025-08-30 23:30:26 +05:30

106 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>File Share</title>
<script src="https://cdn.jsdelivr.net/npm/particles.js"></script>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
background: #0d0d0d;
color: #fff;
text-align: center;
}
#particles-js {
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
z-index: -1;
}
.container {
margin-top: 100px;
}
button, input[type="file"] {
margin: 10px;
padding: 10px 20px;
background: #1a1a1a;
color: #fff;
border: 1px solid #333;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background: #333;
}
ul {
list-style: none;
padding: 0;
}
li {
margin: 10px 0;
}
a {
color: #4db8ff;
text-decoration: none;
margin-right: 10px;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div id="particles-js"></div>
<div class="container">
<h1>File Share</h1>
<form id="uploadForm" enctype="multipart/form-data">
<input type="file" name="file" required>
<button type="submit">Upload</button>
</form>
<h2>Available Files</h2>
<ul id="fileList"></ul>
</div>
<script>
// Particle background
particlesJS.load('particles-js', 'https://cdn.jsdelivr.net/gh/VincentGarreau/particles.js/demo/particles.json');
// Fetch file list
async function fetchFiles() {
const res = await fetch('/files');
const files = await res.json();
const fileList = document.getElementById('fileList');
fileList.innerHTML = '';
files.forEach(file => {
const li = document.createElement('li');
li.innerHTML = `
<a href="/uploads/${file}" download>${file}</a>
<button onclick="deleteFile('${file}')">Delete</button>
`;
fileList.appendChild(li);
});
}
// Upload file
document.getElementById('uploadForm').addEventListener('submit', async e => {
e.preventDefault();
const formData = new FormData(e.target);
await fetch('/upload', {
method: 'POST',
body: formData
});
e.target.reset();
fetchFiles();
});
// Delete file
async function deleteFile(filename) {
await fetch(`/delete/${filename}`, { method: 'DELETE' });
fetchFiles();
}
fetchFiles();
</script>
</body>
</html>