Spaces:
Running
Running
Nifemi Alpine Durin
commited on
Commit
·
1ae4512
1
Parent(s):
f66af7a
fix
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ def generate_image(campaign_details):
|
|
16 |
# Define your payload/data to send to the image generation API
|
17 |
data = {
|
18 |
"request_string": campaign_details,
|
19 |
-
"is_single_image":
|
20 |
}
|
21 |
|
22 |
# Make the API call
|
@@ -27,17 +27,12 @@ def generate_image(campaign_details):
|
|
27 |
print(f"Error {response.status_code}: {response.text}")
|
28 |
return "Error: Unable to fetch image from the external API."
|
29 |
|
30 |
-
|
31 |
-
image_directory = "images"
|
32 |
-
if not os.path.exists(image_directory):
|
33 |
-
os.makedirs(image_directory)
|
34 |
|
35 |
-
|
|
|
36 |
|
37 |
-
|
38 |
-
image_file.write(response.content)
|
39 |
-
|
40 |
-
return image_path
|
41 |
|
42 |
|
43 |
content_html = """
|
@@ -95,11 +90,11 @@ Your sub-heading text here.
|
|
95 |
---
|
96 |
|
97 |
## Image Layout
|
98 |
-
### Select Layout
|
99 |
-
Layout can be any of: Mobile Portrait (750x1334), Mobile Landscape (940x470), Square (2048x2048)
|
100 |
-
|
101 |
Selected Layout: Mobile Portrait (750x1334)
|
102 |
|
|
|
|
|
|
|
103 |
---
|
104 |
|
105 |
## Custom Graphics
|
|
|
16 |
# Define your payload/data to send to the image generation API
|
17 |
data = {
|
18 |
"request_string": campaign_details,
|
19 |
+
"is_single_image": False
|
20 |
}
|
21 |
|
22 |
# Make the API call
|
|
|
27 |
print(f"Error {response.status_code}: {response.text}")
|
28 |
return "Error: Unable to fetch image from the external API."
|
29 |
|
30 |
+
image_data = response.json()
|
|
|
|
|
|
|
31 |
|
32 |
+
data_url = image_data['image_url']
|
33 |
+
image_desc = image_data['image_description']
|
34 |
|
35 |
+
return data_url
|
|
|
|
|
|
|
36 |
|
37 |
|
38 |
content_html = """
|
|
|
90 |
---
|
91 |
|
92 |
## Image Layout
|
|
|
|
|
|
|
93 |
Selected Layout: Mobile Portrait (750x1334)
|
94 |
|
95 |
+
**Examples of layouts: Mobile Portrait (750x1334), Mobile Landscape (940x470), Square (2048x2048)
|
96 |
+
|
97 |
+
|
98 |
---
|
99 |
|
100 |
## Custom Graphics
|