-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
134 lines (118 loc) · 4.01 KB
/
index.html
File metadata and controls
134 lines (118 loc) · 4.01 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Image Generator</title>
<style>
*{
margin: 0;padding: 0;box-sizing: border-box;
}
body {
height: 100vh;
font-family: Arial, sans-serif;
margin: 0;
text-align: center;
background-size: 100% 100%;
background-image: linear-gradient(120deg, #f4e2a9 0%, #f59d85 100%);
background-repeat: no-repeat;
}
h1{
height: 70px;
font-size: 35px;
/* background-image: linear-gradient(to right, #434343 0%, black 100%); */
background-color: #de6e4f;
display: flex;
justify-content: center;
align-items: center;
color: rgb(255, 255, 255);
}
h1 span{
color: rgb(14, 14, 14);
margin: 0px 20px;
font-family: 'Bauhaus 93';
font-weight: 400;
}
#image-container {
margin-top: 20px;
width: 400px;
height: 350px;
background-color: rgb(221, 221, 221);
margin: 50px auto;
display: flex;
justify-content: center;
align-items: center;
border: 3px solid rgb(84, 84, 84);
}
label{
font-size: 25px;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
font-weight: bold;
}
#imageForm{
margin-top: 50px;
}
input{
padding: 10px;
width: 700px;
margin-top: 10px;
font-size: 18px;
font-family:'Times New Roman', Times, serif;
outline: none;
border: none;
box-shadow: 2px 2px 5px 2px rgb(126, 126, 126);
height: 50px;
}
img {
width: 100%;
height: 100%;
}
button{
width: 200px;
height: 50px;
color: white;
font-size: 20px;
background-color: #de924f;
cursor: pointer;
/* font-weight: bold; */
/* letter-spacing: 1px; */
}
</style>
</head>
<body>
<h1>Generate an Image with <span> VisionBox </span> AI</h1>
<form id="imageForm">
<label for="prompt">Enter a prompt:</label><br>
<input type="text" id="prompt" name="prompt" placeholder="Describe an image..." required>
<br><br>
<button type="submit">Generate Image</button>
</form>
<div id="image-container"></div>
<script>
const form = document.getElementById('imageForm');
const imageContainer = document.getElementById('image-container');
form.addEventListener('submit', async (e) => {
e.preventDefault();
const prompt = document.getElementById('prompt').value;
imageContainer.innerHTML = 'Generating image...';
try {
const response = await fetch('http://localhost:3000/generate-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ prompt })
});
if (!response.ok) {
throw new Error('Failed to generate image');
}
const data = await response.json();
const imageUrl = data.imageUrl;
imageContainer.innerHTML = `<img src="${imageUrl}" alt="Generated Image">`;
} catch (error) {
imageContainer.innerHTML = 'Error generating image. Please try again.';
}
});
</script>
</body>
</html>