Spaces:
Sleeping
Sleeping
Create templates/index.html
Browse files- templates/index.html +46 -0
templates/index.html
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- templates/index.html -->
|
2 |
+
<!DOCTYPE html>
|
3 |
+
<html lang="en">
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<title>File2Link Uploader</title>
|
7 |
+
<style>
|
8 |
+
body { font-family: sans-serif; margin: 40px; }
|
9 |
+
input[type="file"] { margin-bottom: 10px; }
|
10 |
+
#response { margin-top: 20px; font-family: monospace; white-space: pre-wrap; }
|
11 |
+
</style>
|
12 |
+
</head>
|
13 |
+
<body>
|
14 |
+
<h2>π Upload File to Internet Archive</h2>
|
15 |
+
<form id="uploadForm">
|
16 |
+
<input type="file" name="file" required>
|
17 |
+
<br>
|
18 |
+
<button type="submit">Upload</button>
|
19 |
+
</form>
|
20 |
+
|
21 |
+
<div id="response"></div>
|
22 |
+
|
23 |
+
<script>
|
24 |
+
const form = document.getElementById('uploadForm');
|
25 |
+
const responseDiv = document.getElementById('response');
|
26 |
+
|
27 |
+
form.onsubmit = async (e) => {
|
28 |
+
e.preventDefault();
|
29 |
+
const formData = new FormData(form);
|
30 |
+
responseDiv.innerHTML = 'Uploading...';
|
31 |
+
|
32 |
+
const res = await fetch('/upload', {
|
33 |
+
method: 'POST',
|
34 |
+
body: formData
|
35 |
+
});
|
36 |
+
|
37 |
+
const data = await res.json();
|
38 |
+
if (data.success) {
|
39 |
+
responseDiv.innerHTML = 'β
File uploaded!\n' + JSON.stringify(data, null, 2);
|
40 |
+
} else {
|
41 |
+
responseDiv.innerHTML = 'β Error:\n' + JSON.stringify(data, null, 2);
|
42 |
+
}
|
43 |
+
};
|
44 |
+
</script>
|
45 |
+
</body>
|
46 |
+
</html>
|