in content/lab_assets/start/lab5/cfn-project/lambda_functions/source/SurveySubmit/survey_submit.py [0:0]
def lambda_handler(event, context):
account_id = acc_id_from_arn(context.invoked_function_arn)
table = get_ddb_table(account_id)
timestamp = int(datetime.now().timestamp() * 1000000)
item_data = {'id': str(account_id), 'timestamp': timestamp}
for param in event["queryStringParameters"]:
value = event["queryStringParameters"][param]
if not value:
value = "-"
item_data[param] = value
table.put_item(
Item=item_data
)
doc, tag, text = Doc().tagtext()
with tag('html'):
with tag('body'):
with tag('div', align='center'):
with tag('h1'):
count = 0
while count < 6:
count += 1
doc.stag('br')
text("Your answer was submitted!")
html_result = doc.getvalue()
return {
'statusCode': "200",
'body': html_result,
'headers': {
'Content-Type': 'text/html',
"Refresh": "5;url=newsurvey",
}
}