Our great sponsors
-
serverless-userpics
⚡ Instantly get user avatars via 1 API call. Ready to use. 100 artsy avatars included. Made open-source by DevClad.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
def random_avatar(): name = str(uuid.uuid4())[:8] with open(f"media/avatars/{name}.png", "wb+") as f: url = requests.get("https://userpics.devclad.com/api/getpic") response = requests.get(url.text, stream=True) if not response.ok: raise Exception("Could not get avatar") for block in response.iter_content(1024): if not block: break f.write(block) return f"avatars/{name}.png"