Spaces:
Runtime error
Runtime error
File size: 1,151 Bytes
55450db |
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 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image to Sketch</title>
</head>
<body>
<h1>Image to Sketch</h1>
<form action="/upload/" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit">Upload</button>
</form>
<div id="result"></div>
<script>
async function uploadFile() {
const formData = new FormData();
const fileInput = document.querySelector('input[type="file"]');
formData.append('file', fileInput.files[0]);
const response = await fetch('/upload/', {
method: 'POST',
body: formData
});
const data = await response.json();
document.getElementById('result').innerHTML = `<img src="data:image/png;base64,${data.sketch_image}" />`;
}
document.querySelector('form').addEventListener('submit', function(event) {
event.preventDefault();
uploadFile();
});
</script>
</body>
</html>
|