(payload)
| 58 | |
| 59 | |
| 60 | def process_incoming_request(payload): |
| 61 | parsed_data = json.loads(payload) |
| 62 | data = parsed_data["data"] |
| 63 | style = parsed_data["style"] |
| 64 | |
| 65 | # Convert to PIL image |
| 66 | image = data[data.find(",") + 1:] |
| 67 | dec = base64.b64decode(image + "===") |
| 68 | image = Image.open(BytesIO(dec)) |
| 69 | |
| 70 | # Process the image |
| 71 | cartoon_img = cartoonify(image, style) |
| 72 | |
| 73 | result = { |
| 74 | "output": base64_encode_img(cartoon_img), |
| 75 | } |
| 76 | return result |
| 77 | |
| 78 | |
| 79 | @app.get("/") |
no test coverage detected