diff options
Diffstat (limited to 'templates/index.html')
| -rw-r--r-- | templates/index.html | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..220c8c9 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,32 @@ +<!DOCTYPE HTML> +<html> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title>box</title> + <script> + function upload() { + f = document.getElementById("file").files[0]; + const xhr = new XMLHttpRequest(); + xhr.upload.addEventListener("progress", (e) => { + p = document.getElementById("progress") + ratio = e.loaded / e.total; + perc = Math.floor(ratio * 100); + p.innerHTML = perc + "%"; + }); + xhr.open("POST", "/" + f.name, true); + xhr.send(f) + /*const response = await fetch("/" + name, { + method: "POST", + body: f, + });*/ + } + </script> + </head> + <body> + <h1>Box</h1> + <pre>Server for uploading files. Use the form here or send a POST request to /[filename] with the content of the file in the body.</pre> + <input type="file" id="file"/><br/><br/> + <button type="button" onclick="upload()">Upload</button><br/> + <span id="progress"></span> + </body> +</html> |
