Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy minimal python example #26

Merged
merged 3 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/minimal-python/aws_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
aws-xray-sdk
requests
firetail-lambda
20 changes: 11 additions & 9 deletions examples/minimal-python/handler.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import sys, base64, datetime, json, os, time
import datetime
import json
import sys

# Deps in src/vendor
sys.path.insert(0, 'src/vendor')
import requests

from firetail_lambda import firetail_handler, firetail_app
from firetail_lambda import firetail_handler, firetail_app # noqa: E402
app = firetail_app()

from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
patch_all()

@firetail_handler(app)
def endpoint(event, context):
current_time = datetime.datetime.now().time()
return {
"statusCode": 200,
"body": json.dumps({
"message": "Hello, the current time is %s" % datetime.datetime.now().time()
})
}
"message": "Hello, the current time is %s" % current_time
}),
"headers": {
"Current-Time": "%s" % current_time
}
}