(event, context)
| 35 | |
| 36 | |
| 37 | def handler(event, context): |
| 38 | print(event) |
| 39 | # Generate random image id |
| 40 | image_id = str(uuid.uuid4()) |
| 41 | |
| 42 | data = json.loads(event['body']) |
| 43 | userid = data['userid'] |
| 44 | img = base64.b64decode(data['photo']) |
| 45 | |
| 46 | if upload_image(image_id, img, userid): |
| 47 | return { |
| 48 | 'statusCode': 200, |
| 49 | 'headers': { |
| 50 | 'Access-Control-Allow-Headers': '*', |
| 51 | 'Access-Control-Allow-Origin': '*', |
| 52 | 'Access-Control-Allow-Methods': 'OPTIONS,POST,GET' |
| 53 | }, |
| 54 | 'body': json.dumps('Success!') |
| 55 | } |
| 56 | return { |
| 57 | 'statusCode': 500, |
| 58 | 'headers': { |
| 59 | 'Access-Control-Allow-Headers': '*', |
| 60 | 'Access-Control-Allow-Origin': '*', |
| 61 | 'Access-Control-Allow-Methods': 'OPTIONS,POST,GET' |
| 62 | }, |
| 63 | 'body': json.dumps('Request Failed!') |
| 64 | } |
nothing calls this directly
no test coverage detected