host / templates /index.html
Jiakaaa's picture
Create templates/index.html
a274330 verified
Raw History Blame Contribute Delete
1.35 kB
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>批量登录测试</title>
<style>
body { font-family: sans-serif; padding: 1rem; }
textarea { width: 100%; height: 300px; margin-top: 1rem; }
</style>
</head>
<body>
<h2>上传 hosts.csv</h2>
<form id="upload-form" enctype="multipart/form-data">
<input type="file" name="file" required>
<button type="submit">上传</button>
</form>
<h3>操作</h3>
<button onclick="startTest()">开始测试</button>
<a href="/download" target="_blank">下载结果</a>
<h3>进度</h3>
<textarea id="output" readonly></textarea>
<script>
document.getElementById("upload-form").onsubmit = function (e) {
e.preventDefault();
let formData = new FormData(this);
fetch("/upload", {
method: "POST",
body: formData
}).then(() => alert("上传成功!"));
};
function startTest() {
fetch("/start", { method: "POST" });
}
setInterval(() => {
fetch("/progress")
.then(res => res.json())
.then(data => {
document.getElementById("output").value = data.join("\n");
});
}, 2000);
</script>
</body>
</html>