[server]: Add return_all_data
This commit is contained in:
23
server/src/functions/return_all_data/lambda_function.py
Normal file
23
server/src/functions/return_all_data/lambda_function.py
Normal file
@ -0,0 +1,23 @@
|
||||
import boto3
|
||||
import json
|
||||
import os
|
||||
|
||||
dynamodb = boto3.resource('dynamodb')
|
||||
table = dynamodb.Table(os.environ['TABLE_NAME'])
|
||||
|
||||
def lambda_handler(event, context):
|
||||
try:
|
||||
response = table.scan()
|
||||
|
||||
items = response.get('Items', [])
|
||||
|
||||
return {
|
||||
'statusCode': 200,
|
||||
'body': json.dumps(items)
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
return {
|
||||
'statusCode': 500,
|
||||
'body': json.dumps({'error': str(e)})
|
||||
}
|
Reference in New Issue
Block a user