Imagine / templates /api_docs.html
imseldrith's picture
Update templates/api_docs.html
3ab0a79
raw
history blame
1.67 kB
<!DOCTYPE html>
<html>
<head>
<title>API Documentation</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
h1 {
margin-bottom: 20px;
}
code {
background-color: #f4f4f4;
padding: 5px;
font-family: monospace;
}
</style>
</head>
<body>
<h1>API Documentation</h1>
<h2>Generate Image</h2>
<p>Endpoint: <code>/api/generate</code></p>
<p>Method: <code>POST</code></p>
<p>Request Payload:</p>
<pre>
{
"prompt": "Woman sitting on a table, looking at the sky, seen from behind",
"style": "ANIME_V2",
"ratio": "RATIO_16X9",
"model": "REALISTIC"
}
</pre>
<p>Response:</p>
<pre>
{
"error": "An error occurred while generating the image."
}
</pre>
<p>Sample Code:</p>
<pre>
import requests
url = 'https://imseldrith-imagine.hf.space/api/generate'
headers = {'Content-Type':'application/json'}
payload = {
'prompt': "Woman sitting on a table, looking at the sky, seen from behind",
'style': 'ANIME_V2',
'ratio': 'RATIO_16X9',
'model': 'REALISTIC'
}
response = requests.post(url, json=payload)
if response.status_code == 200:
# Image generation successful
with open('generated_image.jpg', 'wb') as image_file:
image_file.write(response.content)
print('Image saved successfully!')
else:
# Error occurred during image generation
error_data = response.json()
error_message = error_data.get('error', 'Unknown error')
print(f'Failed to generate image: {error_message}')
</pre>
</body>
</html>