cgt2ids7 / app /static /indexlocalgpt.html
khawir's picture
Add application file
0b8378a
raw
history blame
1.08 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display FastAPI Image</title>
</head>
<body>
<div id="imageContainer"></div>
<script type="text/javascript">
async function query(data) {
const response = await fetch(
`http://127.0.0.1:7860/t2i/?prompt=${encodeURIComponent(data.prompt)}`,
);
if (!response.ok) {
console.error('Failed to fetch image:', response.statusText);
return null;
}
return response.text();
}
query({ "prompt": "a night painting with house, mountains, trees, lake, moon, stars",
"steps": 8,
"guide": 1.5
}).then((base64String) => {
if (base64String) {
const imageElement = document.createElement('img');
imageElement.src = `data:image/png;base64,${base64String}`;
const imageContainer = document.getElementById('imageContainer');
imageContainer.appendChild(imageElement);
}
});
</script>
</body>
</html>