Spaces:
Sleeping
Sleeping
imseldrith
commited on
Commit
•
61aa9e5
1
Parent(s):
8319724
Update templates/api_docs.html
Browse files- templates/api_docs.html +12 -4
templates/api_docs.html
CHANGED
@@ -112,7 +112,7 @@
|
|
112 |
<pre>
|
113 |
import requests
|
114 |
|
115 |
-
url = 'https://imseldrith-imagine.hf.space/api/generate'
|
116 |
|
117 |
headers = {'Content-Type':'application/json'}
|
118 |
payload = {
|
@@ -122,10 +122,18 @@ payload = {
|
|
122 |
'model': 'REALISTIC'
|
123 |
}
|
124 |
|
125 |
-
response = requests.post(url,
|
126 |
-
result = response.json()
|
127 |
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
</pre>
|
130 |
</div>
|
131 |
</div>
|
|
|
112 |
<pre>
|
113 |
import requests
|
114 |
|
115 |
+
url = 'https://imseldrith-imagine.hf.space/api/generate'
|
116 |
|
117 |
headers = {'Content-Type':'application/json'}
|
118 |
payload = {
|
|
|
122 |
'model': 'REALISTIC'
|
123 |
}
|
124 |
|
125 |
+
response = requests.post(url, json=payload)
|
|
|
126 |
|
127 |
+
if response.status_code == 200:
|
128 |
+
# Image generation successful
|
129 |
+
with open('generated_image.jpg', 'wb') as image_file:
|
130 |
+
image_file.write(response.content)
|
131 |
+
print('Image saved successfully!')
|
132 |
+
else:
|
133 |
+
# Error occurred during image generation
|
134 |
+
error_data = response.json()
|
135 |
+
error_message = error_data.get('error', 'Unknown error')
|
136 |
+
print(f'Failed to generate image: {error_message}')
|
137 |
</pre>
|
138 |
</div>
|
139 |
</div>
|