inv / templates /index.html
shashwatIDR's picture
Create templates/index.html
51a77b3 verified
<!-- templates/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>File2Link Uploader</title>
<style>
body { font-family: sans-serif; margin: 40px; }
input[type="file"] { margin-bottom: 10px; }
#response { margin-top: 20px; font-family: monospace; white-space: pre-wrap; }
</style>
</head>
<body>
<h2>πŸ“ Upload File to Internet Archive</h2>
<form id="uploadForm">
<input type="file" name="file" required>
<br>
<button type="submit">Upload</button>
</form>
<div id="response"></div>
<script>
const form = document.getElementById('uploadForm');
const responseDiv = document.getElementById('response');
form.onsubmit = async (e) => {
e.preventDefault();
const formData = new FormData(form);
responseDiv.innerHTML = 'Uploading...';
const res = await fetch('/upload', {
method: 'POST',
body: formData
});
const data = await res.json();
if (data.success) {
responseDiv.innerHTML = 'βœ… File uploaded!\n' + JSON.stringify(data, null, 2);
} else {
responseDiv.innerHTML = '❌ Error:\n' + JSON.stringify(data, null, 2);
}
};
</script>
</body>
</html>