-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.html
65 lines (62 loc) · 1.87 KB
/
Index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Large File Converter</title>
<style>
#progress-bar {
width: 100%;
height: 20px;
background-color: #ddd;
margin-top: 10px;
}
#progress-bar div {
height: 100%;
width: 0;
background-color: #4caf50;
text-align: center;
color: white;
}
</style>
</head>
<body>
<h1>Upload Large MP3 and Convert</h1>
<form id="uploadForm">
<input type="file" id="audio" accept=".mp3" required><br><br>
<label for="format">Output Format:</label>
<select name="format" id="format">
<option value="wma">WMA</option>
<option value="wav">WAV</option>
<option value="aac">AAC</option>
</select><br><br>
<button type="button" onclick="startUpload()">Upload & Convert</button>
</form>
<div id="progress-bar">
<div id="progress">0%</div>
</div>
<div id="status"></div>
<script>
const ws = new WebSocket('ws://localhost:8080');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.progress) {
document.getElementById('progress').style.width = data.progress + '%';
document.getElementById('progress').textContent = data.progress + '%';
}
};
async function startUpload() {
const fileInput = document.getElementById('audio');
const formatSelect = document.getElementById('format');
const formData = new FormData();
formData.append('audio', fileInput.files[0]);
const response = await fetch(`/upload?format=${formatSelect.value}`, {
method: 'POST',
body: formData
});
const result = await response.json();
document.getElementById('status').innerText = 'Conversion in progress. Job ID: ' + result.jobId;
}
</script>
</body>
</html>