Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -70,13 +70,11 @@ class IconRequest(BaseModel):
|
|
| 70 |
|
| 71 |
|
| 72 |
class BannerRequest(BaseModel):
|
| 73 |
-
|
| 74 |
-
domain: str
|
| 75 |
primary_color: str
|
| 76 |
|
| 77 |
class GeneralBannerRequest(BaseModel):
|
| 78 |
-
|
| 79 |
-
domain: str
|
| 80 |
|
| 81 |
|
| 82 |
class CustomBannerBaseRequest(BaseModel):
|
|
@@ -110,9 +108,8 @@ class NetworkUnsplashRequest(BaseModel):
|
|
| 110 |
|
| 111 |
|
| 112 |
class CustomBannerRequest(BaseModel):
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
description: str
|
| 116 |
|
| 117 |
|
| 118 |
class Logo(BaseModel):
|
|
@@ -183,8 +180,8 @@ async def create_text_logo(request: LogoRequest):
|
|
| 183 |
@app.post("/generate-banner")
|
| 184 |
async def create_banner(request: BannerRequest):
|
| 185 |
try:
|
| 186 |
-
banner_result = generate_banner(request.
|
| 187 |
-
return JSONResponse(content=
|
| 188 |
except Exception as e:
|
| 189 |
raise HTTPException(
|
| 190 |
status_code=500, detail=f"Error generating banner: {str(e)}"
|
|
@@ -192,62 +189,35 @@ async def create_banner(request: BannerRequest):
|
|
| 192 |
|
| 193 |
|
| 194 |
@app.post("/desktop-banner")
|
| 195 |
-
async def create_desktop_banner(request:
|
| 196 |
-
"""
|
| 197 |
-
Generate a custom desktop banner with specified colors and description
|
| 198 |
-
"""
|
| 199 |
try:
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
request.domain,
|
| 203 |
-
request.primary_color,
|
| 204 |
-
request.description
|
| 205 |
-
)
|
| 206 |
-
return JSONResponse(content=result)
|
| 207 |
except Exception as e:
|
| 208 |
raise HTTPException(
|
| 209 |
-
status_code=500,
|
| 210 |
-
detail=f"Error generating desktop banner: {str(e)}"
|
| 211 |
)
|
| 212 |
|
| 213 |
|
| 214 |
@app.post("/mobile-banner")
|
| 215 |
-
async def create_mobile_banner(request:
|
| 216 |
-
"""
|
| 217 |
-
Generate a custom mobile banner with specified colors and description
|
| 218 |
-
"""
|
| 219 |
try:
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
request.domain,
|
| 223 |
-
request.primary_color,
|
| 224 |
-
request.description
|
| 225 |
-
)
|
| 226 |
-
return JSONResponse(content=result)
|
| 227 |
except Exception as e:
|
| 228 |
raise HTTPException(
|
| 229 |
-
status_code=500,
|
| 230 |
-
detail=f"Error generating mobile banner: {str(e)}"
|
| 231 |
)
|
| 232 |
|
| 233 |
|
| 234 |
@app.post("/ipad-banner")
|
| 235 |
-
async def create_ipad_banner(request:
|
| 236 |
-
"""
|
| 237 |
-
Generate a custom iPad banner with specified colors and description
|
| 238 |
-
"""
|
| 239 |
try:
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
request.domain,
|
| 243 |
-
request.primary_color,
|
| 244 |
-
request.description
|
| 245 |
-
)
|
| 246 |
-
return JSONResponse(content=result)
|
| 247 |
except Exception as e:
|
| 248 |
raise HTTPException(
|
| 249 |
-
status_code=500,
|
| 250 |
-
detail=f"Error generating iPad banner: {str(e)}"
|
| 251 |
)
|
| 252 |
|
| 253 |
|
|
@@ -276,8 +246,8 @@ async def get_banner_images(request: UnsplashRequest):
|
|
| 276 |
@app.post("/generate-network-banner")
|
| 277 |
async def create_network_banner(request: GeneralBannerRequest):
|
| 278 |
try:
|
| 279 |
-
banner_result = generate_network_banner(request.
|
| 280 |
-
return JSONResponse(content=
|
| 281 |
except Exception as e:
|
| 282 |
raise HTTPException(
|
| 283 |
status_code=500, detail=f"Error generating network banner: {str(e)}"
|
|
@@ -296,10 +266,8 @@ async def get_network_banner_images(request: NetworkUnsplashRequest):
|
|
| 296 |
@app.post("/generate-custom-network-banner")
|
| 297 |
async def create_custom_network_banner(request: CustomBannerRequest):
|
| 298 |
try:
|
| 299 |
-
banner_result = generate_custom_network_banner(
|
| 300 |
-
|
| 301 |
-
)
|
| 302 |
-
return JSONResponse(content={"banner": banner_result})
|
| 303 |
except Exception as e:
|
| 304 |
raise HTTPException(
|
| 305 |
status_code=500, detail=f"Error generating custom network banner: {str(e)}"
|
|
@@ -309,8 +277,8 @@ async def create_custom_network_banner(request: CustomBannerRequest):
|
|
| 309 |
@app.post("/generate-byop-banner")
|
| 310 |
async def create_byop_banner(request: GeneralBannerRequest):
|
| 311 |
try:
|
| 312 |
-
banner_result = generate_byop_banner(request.
|
| 313 |
-
return JSONResponse(content=
|
| 314 |
except Exception as e:
|
| 315 |
raise HTTPException(
|
| 316 |
status_code=500, detail=f"Error generating BYOP banner: {str(e)}"
|
|
@@ -329,10 +297,8 @@ async def get_byop_banner_images(request: ByopUnsplashRequest):
|
|
| 329 |
@app.post("/generate-custom-byop-banner")
|
| 330 |
async def create_custom_byop_banner(request: CustomBannerRequest):
|
| 331 |
try:
|
| 332 |
-
banner_result = generate_custom_byop_banner(
|
| 333 |
-
|
| 334 |
-
)
|
| 335 |
-
return JSONResponse(content={"banner": banner_result})
|
| 336 |
except Exception as e:
|
| 337 |
raise HTTPException(
|
| 338 |
status_code=500, detail=f"Error generating custom BYOP banner: {str(e)}"
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
class BannerRequest(BaseModel):
|
| 73 |
+
brand_details: str
|
|
|
|
| 74 |
primary_color: str
|
| 75 |
|
| 76 |
class GeneralBannerRequest(BaseModel):
|
| 77 |
+
brand_details: str
|
|
|
|
| 78 |
|
| 79 |
|
| 80 |
class CustomBannerBaseRequest(BaseModel):
|
|
|
|
| 108 |
|
| 109 |
|
| 110 |
class CustomBannerRequest(BaseModel):
|
| 111 |
+
prompt: str
|
| 112 |
+
brand_details: str
|
|
|
|
| 113 |
|
| 114 |
|
| 115 |
class Logo(BaseModel):
|
|
|
|
| 180 |
@app.post("/generate-banner")
|
| 181 |
async def create_banner(request: BannerRequest):
|
| 182 |
try:
|
| 183 |
+
banner_result = generate_banner(request.brand_details, request.primary_color)
|
| 184 |
+
return JSONResponse(content=banner_result)
|
| 185 |
except Exception as e:
|
| 186 |
raise HTTPException(
|
| 187 |
status_code=500, detail=f"Error generating banner: {str(e)}"
|
|
|
|
| 189 |
|
| 190 |
|
| 191 |
@app.post("/desktop-banner")
|
| 192 |
+
async def create_desktop_banner(request: CustomBannerRequest):
|
|
|
|
|
|
|
|
|
|
| 193 |
try:
|
| 194 |
+
banner_result = generate_desktop_banner(request.prompt, request.brand_details)
|
| 195 |
+
return JSONResponse(content=banner_result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
except Exception as e:
|
| 197 |
raise HTTPException(
|
| 198 |
+
status_code=500, detail=f"Error generating desktop banner: {str(e)}"
|
|
|
|
| 199 |
)
|
| 200 |
|
| 201 |
|
| 202 |
@app.post("/mobile-banner")
|
| 203 |
+
async def create_mobile_banner(request: CustomBannerRequest):
|
|
|
|
|
|
|
|
|
|
| 204 |
try:
|
| 205 |
+
banner_result = generate_mobile_banner(request.prompt, request.brand_details)
|
| 206 |
+
return JSONResponse(content=banner_result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
except Exception as e:
|
| 208 |
raise HTTPException(
|
| 209 |
+
status_code=500, detail=f"Error generating mobile banner: {str(e)}"
|
|
|
|
| 210 |
)
|
| 211 |
|
| 212 |
|
| 213 |
@app.post("/ipad-banner")
|
| 214 |
+
async def create_ipad_banner(request: CustomBannerRequest):
|
|
|
|
|
|
|
|
|
|
| 215 |
try:
|
| 216 |
+
banner_result = generate_ipad_banner(request.prompt, request.brand_details)
|
| 217 |
+
return JSONResponse(content=banner_result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
except Exception as e:
|
| 219 |
raise HTTPException(
|
| 220 |
+
status_code=500, detail=f"Error generating iPad banner: {str(e)}"
|
|
|
|
| 221 |
)
|
| 222 |
|
| 223 |
|
|
|
|
| 246 |
@app.post("/generate-network-banner")
|
| 247 |
async def create_network_banner(request: GeneralBannerRequest):
|
| 248 |
try:
|
| 249 |
+
banner_result = generate_network_banner(request.brand_details)
|
| 250 |
+
return JSONResponse(content=banner_result)
|
| 251 |
except Exception as e:
|
| 252 |
raise HTTPException(
|
| 253 |
status_code=500, detail=f"Error generating network banner: {str(e)}"
|
|
|
|
| 266 |
@app.post("/generate-custom-network-banner")
|
| 267 |
async def create_custom_network_banner(request: CustomBannerRequest):
|
| 268 |
try:
|
| 269 |
+
banner_result = generate_custom_network_banner(request.prompt, request.brand_details)
|
| 270 |
+
return JSONResponse(content=banner_result)
|
|
|
|
|
|
|
| 271 |
except Exception as e:
|
| 272 |
raise HTTPException(
|
| 273 |
status_code=500, detail=f"Error generating custom network banner: {str(e)}"
|
|
|
|
| 277 |
@app.post("/generate-byop-banner")
|
| 278 |
async def create_byop_banner(request: GeneralBannerRequest):
|
| 279 |
try:
|
| 280 |
+
banner_result = generate_byop_banner(request.brand_details)
|
| 281 |
+
return JSONResponse(content=banner_result)
|
| 282 |
except Exception as e:
|
| 283 |
raise HTTPException(
|
| 284 |
status_code=500, detail=f"Error generating BYOP banner: {str(e)}"
|
|
|
|
| 297 |
@app.post("/generate-custom-byop-banner")
|
| 298 |
async def create_custom_byop_banner(request: CustomBannerRequest):
|
| 299 |
try:
|
| 300 |
+
banner_result = generate_custom_byop_banner(request.prompt, request.brand_details)
|
| 301 |
+
return JSONResponse(content=banner_result)
|
|
|
|
|
|
|
| 302 |
except Exception as e:
|
| 303 |
raise HTTPException(
|
| 304 |
status_code=500, detail=f"Error generating custom BYOP banner: {str(e)}"
|