-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
22 lines (18 loc) · 1.07 KB
/
Copy pathmain.py
File metadata and controls
22 lines (18 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from typing import Any
# `data` is the data you encrypted and passed into `evervault.run` from your server. The Function
# automatically decrypts the data and maintains its structure so you can treat event exactly as
# you did when you passed it into `evervault.run`.
def handler(data: Any, context) -> dict[str, str]:
# Check if the data sent into the Function included the `name` key
if "name" in data and isinstance(data["name"], str):
print(f'A name of length {len(data["name"])} has arrived into the Function.')
# Process the decrypted name value, and re-encrypt the original name using the encrypt function available in the context parameter.
return {
"message": f'Hello from a Function! It seems you have {len(data["name"])} letters in your name',
"name": f'{context["encrypt"](data["name"])}',
}
else:
print("An empty name has arrived into the Function.")
return {
"message": "Hello from a Function! Send an encrypted `name` parameter to show Function decryption in action",
}