Spaces:
Paused
Paused
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Cartoonize Image</title> | |
| </head> | |
| <body> | |
| <h1>Cartoonize Image</h1> | |
| <form action="/cartoonize/" method="post" enctype="multipart/form-data"> | |
| <input type="file" name="file"> | |
| <button type="submit">Upload & Cartoonize</button> | |
| </form> | |
| <h2>Result:</h2> | |
| <img id="cartoonized_image" src="" alt="Cartoonized Image"> | |
| <script> | |
| const form = document.querySelector('form'); | |
| const img = document.getElementById('cartoonized_image'); | |
| form.addEventListener('submit', async (e) => { | |
| e.preventDefault(); | |
| const formData = new FormData(form); | |
| const response = await fetch('/cartoonize/', { | |
| method: 'POST', | |
| body: formData | |
| }); | |
| if (response.ok) { | |
| const blob = await response.blob(); | |
| const imgUrl = URL.createObjectURL(blob); | |
| img.src = imgUrl; | |
| } else { | |
| alert('Failed to cartoonize image.'); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |