Spaces:
Running
Running
<!-- templates/index.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> | |