Spaces:
Running
Running
File size: 4,340 Bytes
7913bfb a0dcf47 | 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your App Name</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
background: white;
border-radius: 20px;
padding: 40px;
max-width: 600px;
width: 100%;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
h1 {
color: #333;
margin-bottom: 10px;
}
p {
color: #666;
margin-bottom: 30px;
}
input {
width: 100%;
padding: 15px;
border: 2px solid #e0e0e0;
border-radius: 10px;
font-size: 16px;
margin-bottom: 20px;
}
button {
width: 100%;
padding: 15px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 10px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s;
}
button:hover {
transform: translateY(-2px);
}
button:disabled {
opacity: 0.6;
cursor: not-allowed;
}
#result {
margin-top: 30px;
padding: 20px;
background: #f5f5f5;
border-radius: 10px;
display: none;
}
#result img {
width: 100%;
border-radius: 10px;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>🎨 YSOAI IMAGE GENERATOR</h1>
<p>With YSOAI, Generate Image Fast</p>
<input
type="text"
id="prompt"
placeholder="Enter your prompt..."
value="a cool cat wearing sunglasses"
>
<button onclick="generate()">Generate</button>
<div id="result">
<h3>Result:</h3>
<img id="image" alt="Generated image">
</div>
</div>
<script>
async function generate() {
const prompt = document.getElementById('prompt').value;
const button = document.querySelector('button');
const result = document.getElementById('result');
const img = document.getElementById('image');
// Disable button while generating
button.disabled = true;
button.textContent = 'Generating...';
try {
// Example: Generate image with Pollinations
const imageUrl = `https://image.pollinations.ai/prompt/${encodeURIComponent(prompt)}`;
img.src = imageUrl;
result.style.display = 'block';
// Example: Generate text with Pollinations
// const response = await fetch('https://text.pollinations.ai/openai', {
// method: 'POST',
// headers: { 'Content-Type': 'application/json' },
// body: JSON.stringify({
// messages: [{ role: 'user', content: prompt }],
// model: 'openai'
// })
// });
// const data = await response.json();
// console.log(data.choices[0].message.content);
} catch (error) {
alert('Error: ' + error.message);
} finally {
button.disabled = false;
button.textContent = 'Generate';
}
}
// Allow Enter key to submit
document.getElementById('prompt').addEventListener('keypress', (e) => {
if (e.key === 'Enter') generate();
});
</script>
</body>
</html>
|