diff --git a/imageserver/client.py b/imageserver/client.py new file mode 100644 index 0000000..92f2f2a --- /dev/null +++ b/imageserver/client.py @@ -0,0 +1,40 @@ +# 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() + + +