AdarshJi commited on
Commit
0a7e466
Β·
verified Β·
1 Parent(s): 05d900a

Update templates/index.html

Browse files
Files changed (1) hide show
  1. 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
- </style>
54
- </head>
55
- <body>
56
- <div class="container">
57
- <h1>🌌 Image Generation API</h1>
58
- <p>Generate high-quality AI-powered images using various models and providers.</p>
59
-
60
- <h2>⚑ Available Endpoints</h2>
61
-
62
- <div class="endpoint">
63
- <h3>πŸš€ Generate Image</h3>
64
- <p><strong>Endpoint:</strong> <code>POST /generate/image</code></p>
65
- <p><strong>Description:</strong> Generates an AI image based on the given prompt.</p>
66
- <p><strong>Request Body:</strong></p>
67
- <pre>{
68
- "prompt": "A futuristic cityscape",
69
- "model": "black-forest-labs-flux-1-dev",
70
- "width": 1024,
71
- "height": 1024,
72
- "guidance_scale": 3.5,
73
- "seed": 0,
74
- "provider": "blackforestlabs"
75
- }</pre>
76
- <p><strong>Response Example:</strong></p>
77
- <pre>{
78
- "image_url": "http://adarshji-api.hf.space/images/1234567890.jpg"
79
- }</pre>
80
- </div>
81
-
82
- <div class="endpoint">
83
- <h3>πŸ“Œ Get Available Providers</h3>
84
- <p><strong>Endpoint:</strong> <code>POST /providers</code></p>
85
- <p><strong>Description:</strong> Retrieves a list of supported image providers.</p>
86
- <p><strong>Response Example:</strong></p>
87
- <pre>{
88
- "providers": ["blackforestlabs", "flux", "blackforestlabs-schnell"]
89
- }</pre>
90
- </div>
91
-
92
- <div class="endpoint">
93
- <h3>πŸ“‹ Get Models by Provider</h3>
94
- <p><strong>Endpoint:</strong> <code>GET /generate/image/model</code></p>
95
- <p><strong>Description:</strong> Retrieves available models for a given provider.</p>
96
- <p><strong>Request Body:</strong></p>
97
- <pre>{
98
- "provider": "blackforestlabs"
99
- }</pre>
100
- <p><strong>Response Example:</strong></p>
101
- <pre>{
102
- "models": ["flux-1", "flux-2", "hyper-realistic-v3"]
103
- }</pre>
104
- </div>
105
-
106
- <div class="endpoint">
107
- <h3>🏠 Homepage</h3>
108
- <p><strong>Endpoint:</strong> <code>GET /</code></p>
109
- <p><strong>Description:</strong> Returns this documentation page.</p>
110
- </div>
111
-
112
- <h2>🐍 Python Usage Example</h2>
113
- <p>Here is how you can use the API in Python to generate an image:</p>
114
- <pre><code>import requests
115
-
116
- url = "http://adarshji-api.hf.space/generate/image"
117
-
118
- data = {
119
- "prompt": "A futuristic cityscape",
120
- "model": "black-forest-labs-flux-1-dev",
121
- "width": 1024,
122
- "height": 1024,
123
- "guidance_scale": 3.5,
124
- "seed": 0,
125
- "provider": "blackforestlabs"
126
- }
127
-
128
- response = requests.post(url, json=data)
129
-
130
- if response.status_code == 200:
131
- print("Image URL:", response.json()["image_url"])
132
- else:
133
- print("Error:", response.json())</code></pre>
134
-
135
- <div class="footer">
136
- <p>πŸš€ API v1.0 | Designed for developers</p>
137
- </div>
138
- </div>
139
- </body>
140
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>