Update templates/index.html
Browse files- templates/index.html +241 -140
templates/index.html
CHANGED
@@ -1,140 +1,241 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
<meta charset="UTF-8">
|
5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>Image Generation API</title>
|
7 |
-
<style>
|
8 |
-
body {
|
9 |
-
font-family: 'Arial', sans-serif;
|
10 |
-
background-color: #0d1117;
|
11 |
-
color: #c9d1d9;
|
12 |
-
padding: 20px;
|
13 |
-
}
|
14 |
-
.container {
|
15 |
-
max-width: 850px;
|
16 |
-
margin: auto;
|
17 |
-
background: #161b22;
|
18 |
-
padding: 25px;
|
19 |
-
border-radius: 10px;
|
20 |
-
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.5);
|
21 |
-
border: 1px solid #30363d;
|
22 |
-
}
|
23 |
-
h1 {
|
24 |
-
color: #58a6ff;
|
25 |
-
text-align: center;
|
26 |
-
}
|
27 |
-
h2, h3 {
|
28 |
-
color: #1f6feb;
|
29 |
-
}
|
30 |
-
p {
|
31 |
-
line-height: 1.6;
|
32 |
-
}
|
33 |
-
.endpoint {
|
34 |
-
padding: 15px;
|
35 |
-
border-bottom: 1px solid #30363d;
|
36 |
-
}
|
37 |
-
code, pre {
|
38 |
-
display: block;
|
39 |
-
background-color: #0d1117;
|
40 |
-
color: #58a6ff;
|
41 |
-
padding: 10px;
|
42 |
-
border-radius: 5px;
|
43 |
-
font-family: 'Courier New', monospace;
|
44 |
-
white-space: pre-wrap;
|
45 |
-
word-wrap: break-word;
|
46 |
-
border-left: 4px solid #58a6ff;
|
47 |
-
}
|
48 |
-
.footer {
|
49 |
-
text-align: center;
|
50 |
-
margin-top: 20px;
|
51 |
-
color: #8b949e;
|
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 |
-
<p><strong>
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Image Generation API</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: 'Arial', sans-serif;
|
10 |
+
background-color: #0d1117;
|
11 |
+
color: #c9d1d9;
|
12 |
+
padding: 20px;
|
13 |
+
}
|
14 |
+
.container {
|
15 |
+
max-width: 850px;
|
16 |
+
margin: auto;
|
17 |
+
background: #161b22;
|
18 |
+
padding: 25px;
|
19 |
+
border-radius: 10px;
|
20 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.5);
|
21 |
+
border: 1px solid #30363d;
|
22 |
+
}
|
23 |
+
h1 {
|
24 |
+
color: #58a6ff;
|
25 |
+
text-align: center;
|
26 |
+
}
|
27 |
+
h2, h3 {
|
28 |
+
color: #1f6feb;
|
29 |
+
}
|
30 |
+
p {
|
31 |
+
line-height: 1.6;
|
32 |
+
}
|
33 |
+
.endpoint {
|
34 |
+
padding: 15px;
|
35 |
+
border-bottom: 1px solid #30363d;
|
36 |
+
}
|
37 |
+
code, pre {
|
38 |
+
display: block;
|
39 |
+
background-color: #0d1117;
|
40 |
+
color: #58a6ff;
|
41 |
+
padding: 10px;
|
42 |
+
border-radius: 5px;
|
43 |
+
font-family: 'Courier New', monospace;
|
44 |
+
white-space: pre-wrap;
|
45 |
+
word-wrap: break-word;
|
46 |
+
border-left: 4px solid #58a6ff;
|
47 |
+
}
|
48 |
+
.footer {
|
49 |
+
text-align: center;
|
50 |
+
margin-top: 20px;
|
51 |
+
color: #8b949e;
|
52 |
+
}
|
53 |
+
|
54 |
+
h1{
|
55 |
+
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
56 |
+
color: rgb(3, 234, 219);
|
57 |
+
padding: 1em;
|
58 |
+
font-size: 3em;
|
59 |
+
font-weight: bolder;
|
60 |
+
}
|
61 |
+
|
62 |
+
.baseurl{
|
63 |
+
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
64 |
+
text-transform:inherit;
|
65 |
+
position: relative;
|
66 |
+
text-align: center;
|
67 |
+
font-size: 1.3em;
|
68 |
+
}
|
69 |
+
|
70 |
+
.h3{
|
71 |
+
font-size: 1.5em;
|
72 |
+
color: #58a6ff;
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
</style>
|
77 |
+
</head>
|
78 |
+
<body>
|
79 |
+
<div class="container">
|
80 |
+
<h1>Image Generation API</h1>
|
81 |
+
<h2>β‘ Available Endpoints</h2>
|
82 |
+
|
83 |
+
<div class="baseurl">
|
84 |
+
<div>
|
85 |
+
<span class="h3" >[</span>
|
86 |
+
<span>BASEURL</span>
|
87 |
+
<span class="h3">]</span>
|
88 |
+
<span class="h3">:</span>
|
89 |
+
<span>
|
90 |
+
<span class="h3">"</span>
|
91 |
+
<span>HTTPS://ADARSHJI-API.HF.SPACE/</span>
|
92 |
+
<span class="h3">"</span>
|
93 |
+
</span>
|
94 |
+
</div>
|
95 |
+
</div>
|
96 |
+
|
97 |
+
<div class="endpoint">
|
98 |
+
<h3>π Generate Image</h3>
|
99 |
+
<p><strong>Endpoint:</strong> <code>[POST] /generate/image</code></p>
|
100 |
+
<p><strong>Description:</strong> Generates an AI image based on the given prompt.</p>
|
101 |
+
<p><strong>Request Body:</strong></p>
|
102 |
+
<pre>{
|
103 |
+
"prompt": "A futuristic cityscape",
|
104 |
+
"model": "black-forest-labs-flux-1-dev",
|
105 |
+
"width": 1024,
|
106 |
+
"height": 1024,
|
107 |
+
"guidance_scale": 3.5,
|
108 |
+
"seed": 0,
|
109 |
+
"provider": "blackforestlabs"
|
110 |
+
}</pre>
|
111 |
+
<p><strong>Response Example:</strong></p>
|
112 |
+
<pre>{
|
113 |
+
"Result": "http://adarshji-api.hf.space/images/1234567890.jpg"
|
114 |
+
}</pre>
|
115 |
+
</div>
|
116 |
+
|
117 |
+
<div class="endpoint">
|
118 |
+
<h3>π Get Available Providers</h3>
|
119 |
+
<p><strong>Endpoint:</strong> <code>[POST] /providers</code></p>
|
120 |
+
<p><strong>Description:</strong> Retrieves a list of supported image providers.</p>
|
121 |
+
<p><strong>Response Example:</strong></p>
|
122 |
+
<pre>{
|
123 |
+
"providers": ["blackforestlabs", "flux", "blackforestlabs-schnell"]
|
124 |
+
}</pre>
|
125 |
+
</div>
|
126 |
+
|
127 |
+
<div class="endpoint">
|
128 |
+
<h3>π Get Models by Provider</h3>
|
129 |
+
<p><strong>Endpoint:</strong> <code>GET /generate/image/model</code></p>
|
130 |
+
<p><strong>Description:</strong> Retrieves available models for a given provider.</p>
|
131 |
+
<p><strong>Request Body:</strong></p>
|
132 |
+
<pre>{
|
133 |
+
"provider": "blackforestlabs"
|
134 |
+
}</pre>
|
135 |
+
<p><strong>Response Example:</strong></p>
|
136 |
+
<pre>{
|
137 |
+
"models": ["flux-1", "flux-2", "hyper-realistic-v3"]
|
138 |
+
}</pre>
|
139 |
+
</div>
|
140 |
+
|
141 |
+
<div class="endpoint">
|
142 |
+
<h3>π Homepage</h3>
|
143 |
+
<p><strong>Endpoint:</strong> <code>GET /</code></p>
|
144 |
+
<p><strong>Description:</strong> Returns this documentation page.</p>
|
145 |
+
</div>
|
146 |
+
|
147 |
+
<h2>π Python Usage Example</h2>
|
148 |
+
<p>Here is how you can use the API in Python to generate an image:</p>
|
149 |
+
<pre><code>
|
150 |
+
import requests
|
151 |
+
|
152 |
+
BASE_URL = "https://adarshji-api.hf.space/"
|
153 |
+
|
154 |
+
def generate_image(
|
155 |
+
prompt,
|
156 |
+
model="black-forest-labs-flux-1-dev",
|
157 |
+
width=1024,
|
158 |
+
height=1024,
|
159 |
+
guidance_scale=3.5,
|
160 |
+
seed=0,
|
161 |
+
provider="blackforestlabs"
|
162 |
+
):
|
163 |
+
|
164 |
+
url = f"{BASE_URL}/generate/image"
|
165 |
+
|
166 |
+
payload = {
|
167 |
+
"prompt": prompt,
|
168 |
+
"model": model,
|
169 |
+
"width": width,
|
170 |
+
"height": height,
|
171 |
+
"guidance_scale": guidance_scale,
|
172 |
+
"seed": seed,
|
173 |
+
"provider": provider
|
174 |
+
}
|
175 |
+
|
176 |
+
headers = {'Content-Type': 'application/json'}
|
177 |
+
|
178 |
+
response = requests.post(url, json=payload, headers=headers)
|
179 |
+
|
180 |
+
if response.status_code == 200:
|
181 |
+
|
182 |
+
try:
|
183 |
+
data = response.json()
|
184 |
+
print("Image URL:", data)
|
185 |
+
except requests.exceptions.JSONDecodeError:
|
186 |
+
print("Error: Failed to decode JSON response.")
|
187 |
+
|
188 |
+
else:
|
189 |
+
print(f"Error: {response.status_code}, {response.text}")
|
190 |
+
|
191 |
+
def get_providers():
|
192 |
+
|
193 |
+
url = f"{BASE_URL}/providers"
|
194 |
+
|
195 |
+
headers = {'Content-Type': 'application/json'}
|
196 |
+
|
197 |
+
response = requests.get(url, headers=headers)
|
198 |
+
|
199 |
+
if response.status_code == 200:
|
200 |
+
try:
|
201 |
+
data = response.json()
|
202 |
+
print("Available Providers:", data.get("providers"))
|
203 |
+
except requests.exceptions.JSONDecodeError:
|
204 |
+
print("Error: Failed to decode JSON response.")
|
205 |
+
else:
|
206 |
+
print(f"Error: {response.status_code}, {response.text}")
|
207 |
+
|
208 |
+
def get_models(provider="blackforestlabs"):
|
209 |
+
url = f"{BASE_URL}/generate/image/model"
|
210 |
+
payload = {"provider": provider}
|
211 |
+
headers = {'Content-Type': 'application/json'}
|
212 |
+
|
213 |
+
response = requests.post(url, json=payload, headers=headers)
|
214 |
+
|
215 |
+
if response.status_code == 200:
|
216 |
+
try:
|
217 |
+
data = response.json()
|
218 |
+
print(f"Models for {provider}:", data.get("models"))
|
219 |
+
except requests.exceptions.JSONDecodeError:
|
220 |
+
print("Error: Failed to decode JSON response.")
|
221 |
+
else:
|
222 |
+
print(f"Error: {response.status_code}, {response.text}")
|
223 |
+
|
224 |
+
if __name__ == "__main__":
|
225 |
+
print("Getting providers:")
|
226 |
+
get_providers()
|
227 |
+
|
228 |
+
print("\nGetting models for 'blackforestlabs':")
|
229 |
+
get_models("blackforestlabs")
|
230 |
+
|
231 |
+
print("\nGenerating image:")
|
232 |
+
generate_image(prompt="A beautiful sunset over the ocean.")
|
233 |
+
|
234 |
+
</code></pre>
|
235 |
+
|
236 |
+
<div class="footer">
|
237 |
+
<p>π API v1.0 | Designed By ADARSH β€β€</p>
|
238 |
+
</div>
|
239 |
+
</div>
|
240 |
+
</body>
|
241 |
+
</html>
|