-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda_handler.py
More file actions
29 lines (25 loc) · 821 Bytes
/
Copy pathlambda_handler.py
File metadata and controls
29 lines (25 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import json
import logging
from food_service import FoodItemService
# Set up logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# Initialise once outside the handler so warm invocations can reuse it.
service = FoodItemService()
def lambda_handler(event, context):
try:
# For now, we are triggering the "Get All" functionality
items = service.get_all_food_items()
return {
'statusCode': 200,
'body': json.dumps({
'message': 'Successfully retrieved items',
'data': items
})
}
except Exception as e:
logger.error(f"Error in lambda_handler: {str(e)}")
return {
'statusCode': 500,
'body': json.dumps({'error': 'Internal Server Error'})
}