41 lines
828 B
Python
41 lines
828 B
Python
# import aiohttp
|
|
# import aiofiles
|
|
import asyncio
|
|
import requests
|
|
from io import BytesIO
|
|
from PIL import Image
|
|
import shutil
|
|
from random import randint
|
|
|
|
def main():
|
|
print("Starting")
|
|
|
|
img = Image.new('RGB', (25, 25), color = (randint(0, 255), randint(0, 255), randint(0, 255)))
|
|
img = Image.open("/home/jimmy/image.png")
|
|
byte_io = BytesIO()
|
|
img.save(byte_io, 'png')
|
|
byte_io.seek(0)
|
|
|
|
r = requests.post(url='http://localhost:8000?text=cartoon',
|
|
files={
|
|
'my_file': (
|
|
'1.png',
|
|
byte_io,
|
|
'image/png'
|
|
),
|
|
},
|
|
stream=True
|
|
)
|
|
print(r.status_code)
|
|
|
|
if r.status_code == 200:
|
|
byte_io = BytesIO(r.content)
|
|
img = Image.open(byte_io)
|
|
img.show()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|
|
|
|
|