kittenchief commited on
Commit
edc9db2
·
verified ·
1 Parent(s): c90545d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -1,13 +1,29 @@
1
  import gradio as gr
2
  import requests
3
  import numpy as np
 
4
 
5
 
6
  def run(prompt, token):
7
- result = requests.post(
8
  "https://api.workranked.com/ai-web-design",
9
  data={"prompt": prompt, "token": token},
10
- ).json()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  images = result.get("data", {}).get("images")
13
  image = np.array(images[0]) if images else None
@@ -54,6 +70,7 @@ Have an idea or suggestion? Provide feedback directly to me (the developer) at [
54
  ],
55
  [
56
  "1920px, award-winning, Best Mobile User Experience\npurple background, bold sans-serif text, minimalist, two-column layout, app store buttons, centered elements, playful, modern, clean design, colors: pastel purple, white, black\ntemplates, marketplace, pricing, download, connect socials, monetize, audience building, analytics, creators, influencers, small businesses, e-commerce, mobile app, community",
 
57
  None,
58
  ],
59
  [
 
1
  import gradio as gr
2
  import requests
3
  import numpy as np
4
+ from time import sleep
5
 
6
 
7
  def run(prompt, token):
8
+ job = requests.post(
9
  "https://api.workranked.com/ai-web-design",
10
  data={"prompt": prompt, "token": token},
11
+ ).json()["id"]
12
+
13
+ result = {}
14
+ for attempt in range(0, 12):
15
+ gr.Info(f"Waiting for results (attempt {attempt + 1})")
16
+ sleep(10)
17
+
18
+ result = requests.post(
19
+ f"https://api.workranked.com/ai-web-design-result",
20
+ data={"job": job},
21
+ ).json()
22
+ if result.get("output"):
23
+ break
24
+
25
+ if not result.get("output"):
26
+ gr.Error("Sorry, your request timed out. Please try again later...")
27
 
28
  images = result.get("data", {}).get("images")
29
  image = np.array(images[0]) if images else None
 
70
  ],
71
  [
72
  "1920px, award-winning, Best Mobile User Experience\npurple background, bold sans-serif text, minimalist, two-column layout, app store buttons, centered elements, playful, modern, clean design, colors: pastel purple, white, black\ntemplates, marketplace, pricing, download, connect socials, monetize, audience building, analytics, creators, influencers, small businesses, e-commerce, mobile app, community",
73
+ "homepage, 1920px, award-winning, tech\nminimalist, playful, modern, clean design, bold sans-serif text, colors: pastel purple, white, black\nanalytics, small businesses, e-commerce, marketplace, audience building, pricing, download, connect socials, monetize, creators, influencers, mobile app, community",
74
  None,
75
  ],
76
  [