Subbu1304's picture
Create templets/index.html
16728af verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Food Image Generator</title>
<style>
#generated-image {
margin-top: 20px;
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<h1>AI Food Image Generator</h1>
<textarea id="food-description" placeholder="Describe the food (e.g., Spicy Paneer Tikka with grilled vegetables)" rows="4" cols="50"></textarea><br>
<button onclick="generateImage()">Generate Image</button>
<div id="result">
<img id="generated-image" src="" alt="Generated food image will appear here" />
</div>
<script>
async function generateImage() {
const description = document.getElementById("food-description").value;
if (!description) {
alert("Please enter a food description!");
return;
}
const response = await fetch('http://127.0.0.1:5000/generate-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ description })
});
const data = await response.json();
const imageUrl = data.image_url;
document.getElementById("generated-image").src = imageUrl;
}
</script>
</body>
</html>