Spaces:
Runtime error

bodymeasure / index.html
carsten12's picture
Update index.html
4cb31cf verified
Raw History Blame Contribute Delete
1.95 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Body Measurement API Tester</title>
<style>
body { font-family: sans-serif; max-width: 600px; margin: auto; padding: 20px; }
select, input, button, textarea { display: block; margin-top: 10px; width: 100%; padding: 8px; }
textarea { height: 200px; }
</style>
</head>
<body>
<h2>Upload Body Model File & Measure</h2>
<label for="modelFile">Upload Model File</label>
<input type="file" id="modelFile" />
<label for="gender">Select Gender</label>
<select id="gender">
<option value="NEUTRAL">NEUTRAL</option>
<option value="MALE">MALE</option>
<option value="FEMALE">FEMALE</option>
</select>
<label for="shape">Shape Coefficients (comma-separated 10 floats)</label>
<input type="text" id="shape" value="0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0">
<button onclick="sendRequest()">Measure</button>
<h3>Response</h3>
<textarea id="response" readonly></textarea>
<script>
async function sendRequest() {
const fileInput = document.getElementById("modelFile");
const file = fileInput.files[0];
if (!file) {
alert("Please upload a model file.");
return;
}
const gender = document.getElementById("gender").value;
const shape = document.getElementById("shape").value
.split(",")
.map(parseFloat);
const formData = new FormData();
formData.append("model_file", file);
formData.append("gender", gender);
formData.append("shape", JSON.stringify(shape));
try {
const res = await fetch("/measure", {
method: "POST",
body: formData
});
const json = await res.json();
document.getElementById("response").value = JSON.stringify(json, null, 2);
} catch (err) {
document.getElementById("response").value = err.toString();
}
}
</script>
</body>
</html>