-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget.py
More file actions
22 lines (18 loc) · 708 Bytes
/
get.py
File metadata and controls
22 lines (18 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import json, boto3, os
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table(os.environ['TABLE_NAME'])
def handler(event, context):
session_code = event['queryStringParameters']['session_code']
response = table.get_item(Key={'session_code': session_code})
if 'Item' not in response:
return {
'statusCode': 404,
'headers': {'Access-Control-Allow-Origin': '*'},
'body': json.dumps({'error': 'Code not found or expired'})
}
item = response['Item']
return {
'statusCode': 200,
'headers': {'Access-Control-Allow-Origin': '*'},
'body': json.dumps({'ciphertext': item['ciphertext'], 'iv': item['iv']})
}