20 lines
732 B
Python
20 lines
732 B
Python
#!/usr/bin/env python3
|
|
import urllib.request as u, json
|
|
req = u.Request("http://localhost:9090/api/proxy/image",
|
|
data=json.dumps({"prompt":"a cat on a boat","width":512,"height":512,"steps":4,"cfg_scale":1.0,"sampler":"euler","scheduler":"smoothstep"}).encode(),
|
|
headers={"Content-Type":"application/json"})
|
|
try:
|
|
r = u.urlopen(req, timeout=300)
|
|
body = r.read()
|
|
print("STATUS:", r.status)
|
|
print("LEN:", len(body))
|
|
d = json.loads(body)
|
|
if d.get("data"):
|
|
print("IMAGE_B64_LEN:", len(d["data"][0].get("b64_json","")))
|
|
else:
|
|
print("NO DATA:", body[:300])
|
|
except Exception as e:
|
|
print("ERROR:", type(e).__name__, e)
|
|
if hasattr(e, 'read'):
|
|
print("BODY:", e.read()[:500])
|