0

I made an api request with the url argument, got an image of the api's response, how can I store this image in bytes and show it from its bytes with python?

My code:

@wickenz.command()
    async def meme123(self, ctx):
        payload = b'url=https://i.stack.imgur.com/D3z44.png?s=256&g=1'
        headers = {f'Authorization': 'Bearer {token}','Content-Type': 'application/x-www-form-urlencoded'}
        async with aiohttp.ClientSession() as session:
            async with session.post("https://v1.api.amethyste.moe/generate/beautiful", data=payload, headers=headers) as resp:
                if resp.status != 200:
                    return await channel.send('Could not download file...')
                data = io.BytesIO(await resp.read())
                file=nextcord.File(data, 'cool_image.png')
                embed_test = nextcord.Embed(title="Just a test")
                embed_test.set_thumbnail(url=file)
                await ctx.send(embed=embed_test)

I'm sorry if I wasn't clear.

check this image

shadowoff09
  • 31
  • 1
  • 6

0 Answers0