imseldrith commited on
Commit
3ab0a79
·
1 Parent(s): ff794e8

Update templates/api_docs.html

Browse files
Files changed (1) hide show
  1. templates/api_docs.html +70 -1
templates/api_docs.html CHANGED
@@ -1 +1,70 @@
1
- <h1>API</h1>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>API Documentation</title>
5
+ <style>
6
+ body {
7
+ font-family: Arial, sans-serif;
8
+ padding: 20px;
9
+ }
10
+
11
+ h1 {
12
+ margin-bottom: 20px;
13
+ }
14
+
15
+ code {
16
+ background-color: #f4f4f4;
17
+ padding: 5px;
18
+ font-family: monospace;
19
+ }
20
+ </style>
21
+ </head>
22
+ <body>
23
+ <h1>API Documentation</h1>
24
+ <h2>Generate Image</h2>
25
+ <p>Endpoint: <code>/api/generate</code></p>
26
+ <p>Method: <code>POST</code></p>
27
+ <p>Request Payload:</p>
28
+ <pre>
29
+ {
30
+ "prompt": "Woman sitting on a table, looking at the sky, seen from behind",
31
+ "style": "ANIME_V2",
32
+ "ratio": "RATIO_16X9",
33
+ "model": "REALISTIC"
34
+ }
35
+ </pre>
36
+ <p>Response:</p>
37
+ <pre>
38
+ {
39
+ "error": "An error occurred while generating the image."
40
+ }
41
+ </pre>
42
+ <p>Sample Code:</p>
43
+ <pre>
44
+ import requests
45
+
46
+ url = 'https://imseldrith-imagine.hf.space/api/generate'
47
+
48
+ headers = {'Content-Type':'application/json'}
49
+ payload = {
50
+ 'prompt': "Woman sitting on a table, looking at the sky, seen from behind",
51
+ 'style': 'ANIME_V2',
52
+ 'ratio': 'RATIO_16X9',
53
+ 'model': 'REALISTIC'
54
+ }
55
+
56
+ response = requests.post(url, json=payload)
57
+
58
+ if response.status_code == 200:
59
+ # Image generation successful
60
+ with open('generated_image.jpg', 'wb') as image_file:
61
+ image_file.write(response.content)
62
+ print('Image saved successfully!')
63
+ else:
64
+ # Error occurred during image generation
65
+ error_data = response.json()
66
+ error_message = error_data.get('error', 'Unknown error')
67
+ print(f'Failed to generate image: {error_message}')
68
+ </pre>
69
+ </body>
70
+ </html>